问题描述
尝试提供静态文件,我被放在上面的链接上。
Trying to serve static files i was put on to the above link.
该链接告诉我在开发中提供静态文件时
The link tells me when serving static files in development
- 将静态文件放在他们被找到的位置,home / jamie / mysite / static /'
完成!
2.确保您的INSTALLED_APPS中包含django.contrib.staticfiles。
对于本地开发,如果您正在使用runserver ... ,那么您完成了设置。
完成!
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.您可能需要在模板中引用这些文件。最简单的方法是使用包含的上下文处理器,它允许模板代码如下所示:
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" />
完成!
太简单了,肯定不行,
,可悲的是没有。当我检查,等于无,
Wow, that seems too simple, surely it wouldn't work,and sadly, no.
{{STATIC_URL}}。现在默认情况下STATIC_URL是none,所以这些指令没有做到这一点。当然我做错了,django文档是对的。但我不知道在三个简单的步骤中我出错了。
{{ 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.
推荐答案
尝试设置 STATIC_URL ='/ static /'
code> settings.py 。
Try setting STATIC_URL = '/static/'
in your settings.py
.
这篇关于django文档,提供静态文件,3个简单的步骤?不的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!