in my app, i want to use a css file, but the tempalte doesn’t ‘know’ where the file is, though i’ve configured it as in tutorials:
in the urls.py (the urls file in the root of the site, not belonging to an app)
(r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.STATIC_DOC_ROOT}),
in the template
<link href="/site_media/default.css" rel="stylesheet" type="text/css" />
in the settings:
STATIC_DOC_ROOT = '/site_media'
where can i be wrong?
Thanks
Check django-annoying, it’s a very useful app with plenty of convenient decorators, middlewares and functions. If you add
StaticServemiddleware like that, Django will serve static ifDEBUG = Truewithout explicitly setting in urls.py.Second, check your
MEDIA_URL(in your case it’sSTATIC_DOC_ROOT, but you should useMEDIA_URL) andMEDIA_ROOTpath.MEDIA_ROOTshould point to absolute path to your static directory. This is how I do it in setttings.py:You can use the same function to set path to your
templatesdir.