Add debug toolbar
This commit is contained in:
parent
d4b9638a94
commit
d5d0b293f7
3 changed files with 19 additions and 1 deletions
|
@ -1,5 +1,7 @@
|
||||||
from typing import Type
|
from typing import Type
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.http.request import HttpRequest
|
||||||
from wagtail.models import Page
|
from wagtail.models import Page
|
||||||
from wagtail.models import get_page_models as get_wagtail_page_models
|
from wagtail.models import get_page_models as get_wagtail_page_models
|
||||||
|
|
||||||
|
@ -8,3 +10,7 @@ def get_page_models() -> list[Type[Page]]:
|
||||||
page_models = get_wagtail_page_models().copy()
|
page_models = get_wagtail_page_models().copy()
|
||||||
page_models.remove(Page)
|
page_models.remove(Page)
|
||||||
return page_models
|
return page_models
|
||||||
|
|
||||||
|
|
||||||
|
def show_toolbar_callback(request: HttpRequest) -> bool:
|
||||||
|
return settings.DEBUG
|
||||||
|
|
|
@ -135,7 +135,16 @@ WAGTAILSEARCH_BACKENDS = {
|
||||||
BASE_HOSTNAME = env("BASE_HOSTNAME")
|
BASE_HOSTNAME = env("BASE_HOSTNAME")
|
||||||
WAGTAILADMIN_BASE_URL = f"https://{BASE_HOSTNAME}"
|
WAGTAILADMIN_BASE_URL = f"https://{BASE_HOSTNAME}"
|
||||||
|
|
||||||
# Add `django-browser-reload`
|
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
|
# Add django-browser-reload
|
||||||
INSTALLED_APPS.append("django_browser_reload")
|
INSTALLED_APPS.append("django_browser_reload")
|
||||||
MIDDLEWARE.append("django_browser_reload.middleware.BrowserReloadMiddleware")
|
MIDDLEWARE.append("django_browser_reload.middleware.BrowserReloadMiddleware")
|
||||||
|
|
||||||
|
# Add django-debug-toolbar
|
||||||
|
INSTALLED_APPS.append("debug_toolbar")
|
||||||
|
MIDDLEWARE.append("debug_toolbar.middleware.DebugToolbarMiddleware")
|
||||||
|
DEBUG_TOOLBAR_CONFIG = {
|
||||||
|
"SHOW_TOOLBAR_CALLBACK": "website.common.utils.show_toolbar_callback",
|
||||||
|
"RESULTS_CACHE_SIZE": 5,
|
||||||
|
"SHOW_COLLAPSED": True,
|
||||||
|
}
|
||||||
|
|
|
@ -24,6 +24,9 @@ if settings.DEBUG:
|
||||||
# Add django-browser-reload
|
# Add django-browser-reload
|
||||||
urlpatterns.append(path("__reload__/", include("django_browser_reload.urls")))
|
urlpatterns.append(path("__reload__/", include("django_browser_reload.urls")))
|
||||||
|
|
||||||
|
# Add django-debug-toolbar
|
||||||
|
urlpatterns.append(path("__debug__/", include("debug_toolbar.urls")))
|
||||||
|
|
||||||
urlpatterns = urlpatterns + [
|
urlpatterns = urlpatterns + [
|
||||||
# For anything not caught by a more specific rule above, hand over to
|
# 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
|
# Wagtail's page serving mechanism. This should be the last pattern in
|
||||||
|
|
Loading…
Reference in a new issue