Debug toolbar is only available when DEBUG is True.

This commit is contained in:
Víðir Valberg Guðmundsson 2022-08-09 16:33:56 +02:00
parent 5d3f924873
commit f8688de23a
3 changed files with 18 additions and 4 deletions

View file

@ -5,7 +5,7 @@ description = ""
authors = ["Your Name <you@example.com>"] authors = ["Your Name <you@example.com>"]
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.9" python = "^3.10"
Django = "^4.0" Django = "^4.0"
django-money = "^1.3" django-money = "^1.3"
django-allauth = "^0.46" django-allauth = "^0.46"

View file

@ -32,7 +32,6 @@ INSTALLED_APPS = [
"django.contrib.messages", "django.contrib.messages",
"django.contrib.staticfiles", "django.contrib.staticfiles",
"django.contrib.sites", "django.contrib.sites",
"debug_toolbar",
"allauth", "allauth",
"allauth.account", "allauth.account",
"utils", "utils",
@ -40,6 +39,7 @@ INSTALLED_APPS = [
"membership", "membership",
] ]
DATABASES = {"default": env.dj_db_url("DATABASE_URL")} DATABASES = {"default": env.dj_db_url("DATABASE_URL")}
MIDDLEWARE = [ MIDDLEWARE = [
@ -51,7 +51,6 @@ MIDDLEWARE = [
"django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware", "django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware",
"debug_toolbar.middleware.DebugToolbarMiddleware",
] ]
ROOT_URLCONF = "project.urls" ROOT_URLCONF = "project.urls"
@ -136,3 +135,13 @@ ACCOUNT_AUTHENTICATION_METHOD = "email"
ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_SIGNUP_PASSWORD_ENTER_TWICE = False ACCOUNT_SIGNUP_PASSWORD_ENTER_TWICE = False
ACCOUNT_USERNAME_REQUIRED = False ACCOUNT_USERNAME_REQUIRED = False
if DEBUG:
INSTALLED_APPS += ["debug_toolbar"]
MIDDLEWARE += ["debug_toolbar.middleware.DebugToolbarMiddleware"]
# Always show DDT in development for any IP, not just 127.0.0.1 or
# settings.INTERNAL_IPS. This is useful in a docker setup where the
# requesting IP isn't static.
DEBUG_TOOLBAR_CONFIG = {
"SHOW_TOOLBAR_CALLBACK": lambda _x: DEBUG,
}

View file

@ -1,5 +1,6 @@
"""URLs for the membersystem""" """URLs for the membersystem"""
import debug_toolbar import debug_toolbar
from django.conf import settings
from django.contrib import admin from django.contrib import admin
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.urls import include from django.urls import include
@ -15,5 +16,9 @@ urlpatterns = [
path("membership/", membership_overview, name="membership-overview"), path("membership/", membership_overview, name="membership-overview"),
path("accounts/", include("allauth.urls")), path("accounts/", include("allauth.urls")),
path("admin/", admin.site.urls), path("admin/", admin.site.urls),
]
if settings.DEBUG:
urlpatterns += [
path("__debug__/", include(debug_toolbar.urls)), path("__debug__/", include(debug_toolbar.urls)),
] ]