From 55c64d74ff4eb2b49bbb515da4c5cf0b60d0614b Mon Sep 17 00:00:00 2001 From: Tobias Kunze Date: Mon, 23 Jun 2025 11:33:21 +0200 Subject: [PATCH] Make error views only available in dev mode --- src/servala/frontend/urls.py | 15 --------------- src/servala/urls.py | 17 ++++++++++++++++- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/servala/frontend/urls.py b/src/servala/frontend/urls.py index 2c801a4..52a048e 100644 --- a/src/servala/frontend/urls.py +++ b/src/servala/frontend/urls.py @@ -1,4 +1,3 @@ -from django.conf import settings from django.urls import include, path from django.views.generic import RedirectView @@ -70,18 +69,4 @@ urlpatterns = [ ), ), path("", RedirectView.as_view(pattern_name="frontend:profile"), name="index"), - # Error page URLs available in all environments - path( - "error404/", - views.custom_404, - {"exception": Exception("Test 404")}, - name="error_404", - ), - path( - "error403/", - views.custom_403, - {"exception": Exception("Test 403")}, - name="error_403", - ), - path("error500/", views.custom_500, name="error_500"), ] diff --git a/src/servala/urls.py b/src/servala/urls.py index ef23afb..43526c8 100644 --- a/src/servala/urls.py +++ b/src/servala/urls.py @@ -6,7 +6,7 @@ from django.urls import path from django.urls.conf import include from django.utils.translation import gettext_lazy as _ -from servala.frontend import urls +from servala.frontend import urls, views admin.site.site_title = _("Servala Admin") admin.site.site_header = _("Servala Management") @@ -26,6 +26,21 @@ urlpatterns = [ if settings.DEBUG: urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + urlpatterns += [ + path( + "error404/", + views.custom_404, + {"exception": Exception("Test 404")}, + name="error_404", + ), + path( + "error403/", + views.custom_403, + {"exception": Exception("Test 403")}, + name="error_403", + ), + path("error500/", views.custom_500, name="error_500"), + ] # Custom error handlers handler404 = "servala.frontend.views.custom_404"