[英]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.