需要明确的是,确实会出现调试工具栏。我的问题是,当我启用调试工具栏时,我的所有 javascript 和 css 文件都无法加载。
我的页面会丢失所有格式,但仍会加载内容。我正在使用 chrome,它在控制台下打印如下内容:
加载资源失败:服务器响应状态为 404 (NOT FOUND) http://127.0.0.1:8000/static/stylesheets/loggedin.css?h=201e99加载资源失败:服务器响应状态为404(未找到) http://127.0.0.1:8000/static/stylesheets/estimates.tabs.css?h=64c8f9加载资源失败:服务器响应状态为 404(未找到) http://127.0 .0.1:8000/static/js/jquery.console-log.js加载资源失败:服务器响应状态为 404 (NOT FOUND) http://127.0.0.1:8000/static/theme/jquery-ui .custom.css加载资源失败:服务器响应状态为 404 (NOT FOUND) http://127.0.0.1:8000/static/js/jquery-ui-timepicker-addon.js?h=7e5e4a加载资源失败:服务器响应状态为 404 (NOT FOUND) http://127.0.0.1:8000/static/js/jquery.if.min.js?h=e69918加载资源失败:服务器响应状态为 404(未找到) http://127.0.0.1:8000/static/js/base.js?h=4b783f加载资源失败:服务器响应状态为 404(未找到) http:/ /127.0.0.1:8000/static/stylesheets/estimates.summary.show.css?h=0dd5d5加载资源失败:服务器响应状态为 404(未找到) http://127.0.0.1:8000/static /js/jquery.floatThead.min.js?h=7f4ca5加载资源失败:服务器响应状态为 404 (NOT FOUND) http://127.0.0.1:8000/static/stylesheets/reset.css?h =fbd5ac加载资源失败:服务器响应状态为 404 (NOT FOUND) http://127.0.0.1:8000/static/js/estimates.section.sortable.js?h=2ea052加载资源失败:服务器响应状态为 404(未找到) http://127.0.0.1:8000/static/stylesheets/loggedin.css?h=201e99加载资源失败:服务器响应状态为 404(未找到) http:/ /127.0.0.1:8000/static/stylesheets/estimates.tabs.css?h=64c8f9加载资源失败:服务器响应状态为 404(未找到) http://127.0.0.1:8000/static/stylesheets /estimates.summary.show.css?h=0dd5d5加载资源失败:服务器响应状态为 404(未找到) http://127.0.0.1:8000/static/stylesheets/reset.css?h=fbd5ac加载资源失败:服务器响应状态为 404(未找到) http://127.0.0.1:8000/static/ stylesheets/base.css?h=fcefb2加载资源失败:服务器响应状态为 404 (NOT FOUND) http://127.0.0.1:8000/static/theme/jquery-ui.custom.css加载失败资源:服务器响应状态为 404(未找到)
我正在使用 debug_toolbar 1.3.2、django1.5.0 和 python 2.7.6
我的项目结构有
project_dir
project
settings
settings.py
static
images
js
scss
stylesheets
在我的设置文件中:
DEBUG = True
DEBUG_TOOLBAR = True
#....middleware
#....other Installed apps
cd_up = lambda x: os.path.split(x)[0]
SETTINGS_DIR = dirname(os.path.abspath(__file__))
APP_DIR = cd_up(SETTINGS_DIR)
PROJ_DIR = cd_up(APP_DIR)
MEDIA_ROOT = '/tmp'
MEDIA_URL = ''
STATIC_URL = '/static/'
STATIC_ROOT = '{}/static/'.format(APP_DIR)
if DEBUG_TOOLBAR:
INSTALLED_APPS += ('django.contrib.staticfiles','debug_toolbar',)
MIDDLEWARE_CLASSES += debug_toolbar.middleware.DebugToolbarMiddleware',)
INTERNAL_IPS = ('127.0.0.1',)
DEBUG_TOOLBAR_PANELS = (
#'debug_toolbar.panels.version.VersionDebugPanel',
#'debug_toolbar.panels.timer.TimerDebugPanel',
#'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
#'debug_toolbar.panels.headers.HeaderDebugPanel',
#'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
#'debug_toolbar.panels.template.TemplateDebugPanel',
'debug_toolbar.panels.sql.SQLDebugPanel',
#'debug_toolbar.panels.signals.SignalDebugPanel',
#'debug_toolbar.panels.logger.LoggingPanel',
)
自然,我无法发送任何 ajax 请求并将 DEBUG_TOOLBAR 设置为 false 可以解决所有问题。
这是一个精简版,但如果需要任何其他信息,我会更新。抱歉,我对 SO 还是有点陌生。谢谢
更新:运行 ./manage.py runserver --insecure 时出现 404 错误
否则资源失败并显示 net::ERR_NETWORK_CONNECTION_RESET 消息