Rodney Topor
unread,Aug 9, 2011, 3:24:20 AM8/9/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
I tried using a style sheet served as a static file with the tutorial
project. In settings.py, I defined STATIC_URL = /static/ and
STATICFILES_DIRS = ('/path/to/project/static/',). Then I defined a
base_html template with a line in the HEAD of the form
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}
style.css" />
and put style.css in directory /static/. Finally, I defined
index.html, detail.html, etc., as given in the tutorial to each extend
base.html.
Everything works perfectly, except that only one template
(detail.html) correctly processes the {{ STATIC_URL }} value to find /
static/style.css. In every other template, {{ STATIC_URL }} evaluates
to the empty string, giving just style.css, which does not exist of
course.
Every template extends the single base template in the same way. So
why does {{ STATIC_URL }} work for some templates and not others?
Rodney