0
votes

https://docs.djangoproject.com/en/1.3/howto/static-files/

Trying to serve static files i was put on to the above link.

The link tells me when serving static files in development

  1. Put your static files where they will be found, 'home/jamie/mysite/static/' Done!

2.Make sure that django.contrib.staticfiles is included in your INSTALLED_APPS. For local development, if you are using runserver...you’re done with the setup. Done!

3.You’ll probably need to refer to these files in your templates. The easiest method is to use the included context processor which allows template code like:

<img src="{{ STATIC_URL }}images/hi.jpg" />

Done!

Wow, that seems too simple, surely it wouldn't work, and sadly, no.

{{ STATIC_URL }} when i checked, equals None. Now STATIC_URL by default is none, therefore these instruction haven't done a thing. Surely i've done something wrong and the django documentation is right. But i cant figure out where in the three simple steps i've gone wrong.

1
what is the value of STATIC_URL in your settings.py?akonsu
I have not touched it as the django documentation never mentions anything about it. Thus the django documentation suggests that you can serve your static files in the templates using the tag {{ STATIC_FILES }} as is.JT.
Yes, it mentions altering STATIC_URLS when you deploy youre project, im nowhere near that. The three steps should work in development according to the documentJT.
at the end of item 2 it says: "your static files will automatically be served at the default (for newly created projects) STATIC_URL of /static/" Your STATIC_URL is not '/static/'. Try to set it to '/static/' in your settings.py.akonsu

1 Answers

1
votes

Try setting STATIC_URL = '/static/' in your settings.py.