I’m having trouble loading CSS for my Django template.
I have the following settings:
STATIC_ROOT = ''
STATIC_URL = '/css/'
STATICFILES_DIRS = ("/css")
INSTALLED_APPS = (
'django.contrib.staticfiles',
)
Do I need to use both static_url and also staticfiles_dirs?
urls.py is
urlpatterns = patterns('',
(r'^$',homefun),
)
views.py is
def homefun(request):
return render_to_response('home.html')
And the parent template is base.html which loads the css.
<link rel="stylesheet" type="text/css" href="/css/style.css" />
Your
STATICFILES_DIRS = ("/css")should actually beSTATICFILES_DIRS = ("/path/to/your/css", )(note the trailing comma — necessary because(eggs)evaluates to the valueeggs, but the trailing comma forces it to evaluate to a tuple).