django文档,提供静态文件,3个简单的步骤?不 [英] django documentation, serving static files, 3 simple steps? Nope

查看:181
本文介绍了django文档,提供静态文件,3个简单的步骤?不的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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. 将静态文件放在他们被找到的位置,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个简单的步骤?不的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆