1.在你的应用目录下创建一个static目录(与templates同级目录下)
2.修改setting.py配置文件
STATIC_URL = '/static/' #在下面追加一行内容
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
3.修改urls.py文件
1)导入两个库
from django.conf import settings
from django.conf.urls.static import static
2)在urlpatterns末尾追加内容
static(settings.STATIC_URL, document_root = settings.STATIC_ROOT)
#最后修改的样子
from django.conf.urls import url
from . import views
#加入的两个库
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
url(r'^index/$', views.index),
#url(r'^article/$', views.article_page),
url(r'^article/(?P<article_id>[0-9]+)$', views.article_page, name='article_page'),
url(r'^video/$', views.video),
url(r'^bimface/$', views.bimface),
url(r'^bimface1/$', views.bimface1),
url(r'^bimface2/$', views.bimface2),
url(r'^dwg/$', views.dwg),
] + static(settings.STATIC_URL, document_root = settings.STATIC_ROOT)
4.重新运行项目
/static/xxx 就可以引用你的文件了
#例如:
config.src = "/static/flag_red.png";