Tuesday, November 22, 2011

Re: How-to for static files?

In your original post you had the url like this:

(r'^home/$','myapp.views.homepage'),

than your the url starts with view instead of home so there might be something wrong.

just paste these files into somthing like dpaste.com

- settings.py
- myapp.views.homepage
- urls.py

cheers


On Nov 23, 2011, at 0:29 , Guillaume Chorn wrote:

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.






No comments:

Post a Comment