Tuesday, November 22, 2011

Re: How-to for static files?

Thank you Ivo.  Your suggestion makes a lot of sense so I tried it out.  Unfortunately, after adding TEMPLATE_CONTEXT_PROCESSORS and its associated tuple into the settings.py file, I tried to restart the development server to see if it worked and it didn't.  I checked the page source again and it's still looking for /view/stylesheet.css.  Am I missing something else?

thanks,
Guillaume

On Tue, Nov 22, 2011 at 10:42 PM, Ivo Brodien <ib@brodien.de> wrote:

 Finally, I have another question.  In my settings.py file, there is actually no section for TEMPLATE_CONTEXT_PROCESSORS.  I have noticed in the documentation

yes.

put this in there:

 ("django.contrib.auth.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.media", "django.core.context_processors.static", "django.core.context_processors.tz", "django.contrib.messages.context_processors.messages")

and try again.

What happens in your template is that {{ STATIC_URL }} is empty because the context processor ""django.core.context_processors.static"" did not put the STATIC_URL into the context. so your path to the file becomes: /view/stylesheet.css instead of /static/stylesheet.css

You have to put the CSS file in a directory called static as mentioned before.





--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment