如何在django中链接我的css,js和图像文件链接
我是Django 1.9.5的新手,并使用Windows作为我的平台。 我有一个问题,将我的CSS,图像和js链接到django templage,
这是我的项目结构

这是我的设置页面
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PROJECT_DIR = os.path.dirname(__file__)
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'statics'),
)
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
这是我的主要url.py页面
from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^mysite/', include('myapp.urls')),
# (r'^media/(?P.*)$', 'django.views.static.serve',
# {'document_root': settings.MEDIA_ROOT}),
url(r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += staticfiles_urlpatterns()

这是我的基本html模板

Github链接我的项目在github我已经尝试了所有可能的组合,但在2天内失败。 任何帮助将被占用,我会感谢你,谢谢
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static 'pathtostaticfile' %}" />
你可以使用statcfiles标签来加载你的静态文件。 使用pathtostaticfile是你的静态文件
更多详情https://docs.djangoproject.com/zh/1.9/intro/tutorial06/
链接地址: http://www.djcxy.com/p/62013.html