[英]STATICFILES on Django 1.6.2
This is my settings.py
这是我的
settings.py
STATIC_URL = '/static/'
TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'templates'),
)
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
My structure is: 我的结构是:
manage.py
myproject
-- __init__.py
-- settings.py
-- urls.py
-- wsgi.py
-- static
----- css
----- img
-------- logo.png
----- scripts
I use the static tag in my html file like this: <img src="{{ STATIC_URL }}img/logo.png">
我在html文件中使用静态标签,如下所示:
<img src="{{ STATIC_URL }}img/logo.png">
But, it is: 但它是:
[Error] Failed to load resource: the server responded with a status of 500 (Internal Server Error) (logo.png, line 0)
I really can't understand this issue on Django 1.6.2 version. 我真的无法理解Django 1.6.2版本上的这个问题。
Could someone help me to solve this issue? 有人可以帮我解决这个问题吗?
Thanks in advance! 提前致谢!
You need to make sure that the django.contrib.staticfiles
app is listed in INSTALLED_APPS
: 您需要确保
django.contrib.staticfiles
应用程序已在INSTALLED_APPS
列出:
INSTALLED_APPS = (
...
'django.contrib.staticfiles'
...
)
Lastly, you need to make sure that DEBUG
is set to True
in settings.py
. 最后,您需要确保在
settings.py
中将DEBUG
设置为True
。
EDIT: 编辑:
Try removing 'django.contrib.staticfiles.finders.DefaultStorageFinder'
from STATICFILES_FINDERS
. 尝试从
STATICFILES_FINDERS
删除'django.contrib.staticfiles.finders.DefaultStorageFinder'
。 Then run $ python manage.py findstatic img/logo.png
然后运行
$ python manage.py findstatic img/logo.png
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.