[英]STATICFILES on Django 1.6.2
这是我的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',
)
我的结构是:
manage.py
myproject
-- __init__.py
-- settings.py
-- urls.py
-- wsgi.py
-- static
----- css
----- img
-------- logo.png
----- scripts
我在html文件中使用静态标签,如下所示: <img src="{{ STATIC_URL }}img/logo.png">
但它是:
[Error] Failed to load resource: the server responded with a status of 500 (Internal Server Error) (logo.png, line 0)
我真的无法理解Django 1.6.2版本上的这个问题。
有人可以帮我解决这个问题吗?
提前致谢!
您需要确保django.contrib.staticfiles
应用程序已在INSTALLED_APPS
列出:
INSTALLED_APPS = (
...
'django.contrib.staticfiles'
...
)
最后,您需要确保在settings.py
中将DEBUG
设置为True
。
编辑:
尝试从STATICFILES_FINDERS
删除'django.contrib.staticfiles.finders.DefaultStorageFinder'
。 然后运行$ python manage.py findstatic img/logo.png
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.