Python Django 1.6.2上的静态文件
这是我的Python Django 1.6.2上的静态文件,python,django,django-settings,Python,Django,Django Settings,这是我的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',
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文件中使用静态标记,如下所示:
但是,它是:
[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\u APPS
中:
INSTALLED_APPS = (
...
'django.contrib.staticfiles'
...
)
最后,您需要确保settings.py
中的DEBUG
设置为True
编辑:
尝试从
staticfiles\u finders
中删除'django.contrib.staticfiles.finders.DefaultStorageFinder'
。然后运行$python manage.py findstatic img/logo.png
django.contrib.staticfiles
并且DEBUG
是True
尝试运行$python manage.py findstatic img/logo.png
并查看它是否找到了它。当我运行它时,我得到这个错误:django.core.exceptions.improveryConfigured:staticfiles finder的存储后端没有有效位置。
您的错误看起来不像Django错误。。。另外,如果您查看呈现页面的源(在浏览器中),它试图获取的图像的URL是什么?