How to link my css, js and image file link in django
I am a newbie in Django 1.9.5 and using windows as my platform. I have a problem to link my css, images and js to django templage,
Here is my project structure

Here is my settings page
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/'
Here is my main url.py page
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()

Here is my base html template

Github link My project in github I have tried all possible combination but failed in 2 days. Any help will be appropriated and I will be grateful to you Thanks
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static 'pathtostaticfile' %}" />
You can using statcfiles tag to load your static file. With pathtostaticfile is your static file
More detail https://docs.djangoproject.com/en/1.9/intro/tutorial06/
链接地址: http://www.djcxy.com/p/62014.html上一篇: “百日草
