To refer to static file assets from a template, ensure you have set the STATIC_URL setting to the URL path where the static files are served.
Next, add the static_url context processor to your TEMPLATE_CONTEXT_PROCESSORS setting:
TEMPLATE_CONTEXT_PROCESSORS = (
'staticfiles.context_processors.static_url',
)
Templates rendered with RequestContext will now have access to a STATIC_URL context variable:
<link href="{{ STATIC_URL }}css/polls.css" rel="stylesheet" type="text/css" />
Warning
Don’t use this on production servers. This feature is only intended for development. Please, don’t shoot yourself in the foot. Thanks.
To serve static media for both MEDIA_URL and STATIC_URL add the following snippet to the end of your primary URL configuration:
from django.conf import settings
from staticfiles.urls import staticfiles_urlpatterns
if settings.DEBUG:
urlpatterns += staticfiles_urlpatterns()