diff --git a/pyproject.toml b/pyproject.toml index b58910d..4fef1d8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ description = "" authors = ["Your Name "] [tool.poetry.dependencies] -python = "^3.9" +python = "^3.10" Django = "^4.0" django-money = "^1.3" django-allauth = "^0.46" diff --git a/src/project/settings.py b/src/project/settings.py index 14691fb..f5b9cea 100644 --- a/src/project/settings.py +++ b/src/project/settings.py @@ -32,7 +32,6 @@ INSTALLED_APPS = [ "django.contrib.messages", "django.contrib.staticfiles", "django.contrib.sites", - "debug_toolbar", "allauth", "allauth.account", "utils", @@ -40,6 +39,7 @@ INSTALLED_APPS = [ "membership", ] + DATABASES = {"default": env.dj_db_url("DATABASE_URL")} MIDDLEWARE = [ @@ -51,7 +51,6 @@ MIDDLEWARE = [ "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", - "debug_toolbar.middleware.DebugToolbarMiddleware", ] ROOT_URLCONF = "project.urls" @@ -136,3 +135,13 @@ ACCOUNT_AUTHENTICATION_METHOD = "email" ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_SIGNUP_PASSWORD_ENTER_TWICE = 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, + } diff --git a/src/project/urls.py b/src/project/urls.py index 0bdf6a6..0f3cb57 100644 --- a/src/project/urls.py +++ b/src/project/urls.py @@ -1,5 +1,6 @@ """URLs for the membersystem""" import debug_toolbar +from django.conf import settings from django.contrib import admin from django.contrib.auth.decorators import login_required from django.urls import include @@ -15,5 +16,9 @@ urlpatterns = [ path("membership/", membership_overview, name="membership-overview"), path("accounts/", include("allauth.urls")), path("admin/", admin.site.urls), - path("__debug__/", include(debug_toolbar.urls)), ] + +if settings.DEBUG: + urlpatterns += [ + path("__debug__/", include(debug_toolbar.urls)), + ]