带鹡鸰的 Django 调试工具栏 404
Django debug toolbar 404 with wagtail
我正在努力 django-debug-toolbar
工作。我遵循了 installation steps 并且我得到了包括统计信息的侧边栏(例如 SQL 2.75 毫秒内的 1 个查询,使用的静态文件 19 个文件,12 个信号的 30 个接收器)这似乎是合法的并表明它正在工作。
但是,当我在给定选项卡上单击以获取更多信息时,我在浏览器中收到 404,并且在控制台中收到此类信息:
"GET /__debug__/render_panel/?store_id=ac74875cfe864b2dab4c6d17c1d1ed5d&panel_id=RequestPanel HTTP/1.1" 404 1791"
站点上的其他页面可以正常工作。
我在urls.py
中尝试了各种配置。这是我目前拥有的:
from __future__ import absolute_import, unicode_literals
from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
from wagtail.wagtailadmin import urls as wagtailadmin_urls
from wagtail.wagtailcore import urls as wagtail_urls
from wagtail.wagtaildocs import urls as wagtaildocs_urls
from search import views as search_views
urlpatterns = [
url(r'^django-admin/', include(admin.site.urls)),
url(r'^admin/', include(wagtailadmin_urls)),
url(r'^documents/', include(wagtaildocs_urls)),
url(r'^search/$', search_views.search, name='search'),
# For anything not caught by a more specific rule above, hand over to
# Wagtail's page serving mechanism. This should be the last pattern in
# the list:
url(r'', include(wagtail_urls)),
# Alternatively, if you want Wagtail pages to be served from a subpath
# of your site, rather than the site root:
# url(r'^pages/', include(wagtail_urls)),
]
import debug_toolbar
urlpatterns += [
url(r'^__debug__/', include(debug_toolbar.urls)),
]
if settings.DEBUG:
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
# Serve static and media files from development server
# urlpatterns = [
# url(r'^__debug__/', include(debug_toolbar.urls)),
# ]
urlpatterns += staticfiles_urlpatterns()
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
我在这里尝试了一些其他配置,包括:
import debug_toolbar
urlpatterns += [
url(r'^__debug__/', include(debug_toolbar.urls)),
]
在 if settings.DEBUG:
块中。
有什么想法吗?
正如评论所说,wagtail url 必须是最后一个模式。
一个选项是将调试工具栏 url 移动到列表的开头:
urlpatterns = [
...
]
if settings.DEBUG:
urlpatterns = [
url(r'^__debug__/', include(debug_toolbar.urls)),
] + urlpatterns
或者您可以从当前位置删除 wagtail 网址,并将它们添加到您的 if settings.DEBUG:
块之后。
if settings.DEBUG:
urlpatterns += [
url(r'^__debug__/', include(debug_toolbar.urls)),
]
urlpatterns += [
url(r'', include(wagtail_urls)),
]
我在里面包含了调试工具栏 url 并在此处 if settings.DEBUG:
阻止,因为这是文档推荐的内容,但这不是它起作用的原因。关键是要确保 wagtail url 出现在最后。
我正在努力 django-debug-toolbar
工作。我遵循了 installation steps 并且我得到了包括统计信息的侧边栏(例如 SQL 2.75 毫秒内的 1 个查询,使用的静态文件 19 个文件,12 个信号的 30 个接收器)这似乎是合法的并表明它正在工作。
但是,当我在给定选项卡上单击以获取更多信息时,我在浏览器中收到 404,并且在控制台中收到此类信息:
"GET /__debug__/render_panel/?store_id=ac74875cfe864b2dab4c6d17c1d1ed5d&panel_id=RequestPanel HTTP/1.1" 404 1791"
站点上的其他页面可以正常工作。
我在urls.py
中尝试了各种配置。这是我目前拥有的:
from __future__ import absolute_import, unicode_literals
from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
from wagtail.wagtailadmin import urls as wagtailadmin_urls
from wagtail.wagtailcore import urls as wagtail_urls
from wagtail.wagtaildocs import urls as wagtaildocs_urls
from search import views as search_views
urlpatterns = [
url(r'^django-admin/', include(admin.site.urls)),
url(r'^admin/', include(wagtailadmin_urls)),
url(r'^documents/', include(wagtaildocs_urls)),
url(r'^search/$', search_views.search, name='search'),
# For anything not caught by a more specific rule above, hand over to
# Wagtail's page serving mechanism. This should be the last pattern in
# the list:
url(r'', include(wagtail_urls)),
# Alternatively, if you want Wagtail pages to be served from a subpath
# of your site, rather than the site root:
# url(r'^pages/', include(wagtail_urls)),
]
import debug_toolbar
urlpatterns += [
url(r'^__debug__/', include(debug_toolbar.urls)),
]
if settings.DEBUG:
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
# Serve static and media files from development server
# urlpatterns = [
# url(r'^__debug__/', include(debug_toolbar.urls)),
# ]
urlpatterns += staticfiles_urlpatterns()
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
我在这里尝试了一些其他配置,包括:
import debug_toolbar
urlpatterns += [
url(r'^__debug__/', include(debug_toolbar.urls)),
]
在 if settings.DEBUG:
块中。
有什么想法吗?
正如评论所说,wagtail url 必须是最后一个模式。
一个选项是将调试工具栏 url 移动到列表的开头:
urlpatterns = [
...
]
if settings.DEBUG:
urlpatterns = [
url(r'^__debug__/', include(debug_toolbar.urls)),
] + urlpatterns
或者您可以从当前位置删除 wagtail 网址,并将它们添加到您的 if settings.DEBUG:
块之后。
if settings.DEBUG:
urlpatterns += [
url(r'^__debug__/', include(debug_toolbar.urls)),
]
urlpatterns += [
url(r'', include(wagtail_urls)),
]
我在里面包含了调试工具栏 url 并在此处 if settings.DEBUG:
阻止,因为这是文档推荐的内容,但这不是它起作用的原因。关键是要确保 wagtail url 出现在最后。