错误(运行django runserver命令时):
NotperlyConfigured:STATICFILES_DIRS设置不应包含STATIC_ROOT设置
我实际上并没有使用django static(这主要是和api服务器)而且我只想让django调试来调试和explain
我的sql查询。所以我拥有的是:
STATIC_DIRECTORY ='/' MEDIA_DIRECTORY ='/ media /' STATIC_URL = S3_URL + STATIC_DIRECTORY MEDIA_URL = S3_URL + MEDIA_DIRECTORY
STATICFILES_STORAGE = 'server.s3utils.StaticRootS3BotoStorage'
DEFAULT_FILE_STORAGE = 'server.s3utils.MediaRootS3BotoStorage'
STATIC_ROOT ='staticfiles'
STATICFILES_DIRS = (
abs_path('staticfiles'),
# ABS_PATH('/static/'), #D either
)oesn't work either
)
编辑:如果我只删除STATICFILES_DIRS错误会更改:
TypeError at /admin/
Error when calling the metaclass bases
function() argument 1 must be code, not str
Request Method: GET
Request URL: http://localhost:8000/admin/
Django Version: 1.6.2
Exception Type: TypeError
Exception Value:
Error when calling the metaclass bases
function() argument 1 must be code, not str
我也试过建议添加
的答案之一 if settings.DEBUG:
import debug_toolbar
urlpatterns += patterns('',
url(r'^__debug__/', include(debug_toolbar.urls)),
)
没有帮助..
我想我错过了一些非常简单的东西(但很讨厌)我很乐意为此提供帮助。
答案 0 :(得分:6)
Django调试工具栏在使用S3BotoStorage时会发生阻塞。我主要想要SQL日志记录,所以将此代码添加到settings.py以禁用StaticFilesPanel对我来说是一种解决方法:
DEBUG_TOOLBAR_PANELS = [
'debug_toolbar.panels.versions.VersionsPanel',
'debug_toolbar.panels.timer.TimerPanel',
'debug_toolbar.panels.settings.SettingsPanel',
'debug_toolbar.panels.headers.HeadersPanel',
'debug_toolbar.panels.request.RequestPanel',
'debug_toolbar.panels.sql.SQLPanel',
# 'debug_toolbar.panels.staticfiles.StaticFilesPanel',
'debug_toolbar.panels.templates.TemplatesPanel',
'debug_toolbar.panels.cache.CachePanel',
'debug_toolbar.panels.signals.SignalsPanel',
'debug_toolbar.panels.logging.LoggingPanel',
'debug_toolbar.panels.redirects.RedirectsPanel',
]
答案 1 :(得分:0)
这django-debug-toolbar explicit-setup 说些什么:
from django.conf import settings
from django.conf.urls import include, patterns, url
if settings.DEBUG:
import debug_toolbar
urlpatterns += patterns('',
url(r'^__debug__/', include(debug_toolbar.urls)),
)
你试过吗?
答案 2 :(得分:0)
我在使用 lambda 创建自定义存储时遇到了同样的错误:
StaticRootS3BotoStorage = lambda: S3Boto3Storage(bucket_name='example-bucket')
将其更改为类解决了问题:
class StaticRootS3BotoStorage(S3Boto3Storage):
bucket_name='example-name'