django documentation, serving static files, 3 simple steps? Nope

大憨熊 提交于 2019-12-12 02:12:51

问题


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:


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



来源:https://stackoverflow.com/questions/7720802/django-documentation-serving-static-files-3-simple-steps-nope

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!