Make error views only available in dev mode
All checks were successful
Tests / test (push) Successful in 24s

This commit is contained in:
Tobias Kunze 2025-06-23 11:33:21 +02:00
parent 357fea64d1
commit 55c64d74ff
2 changed files with 16 additions and 16 deletions

View file

@ -1,4 +1,3 @@
from django.conf import settings
from django.urls import include, path from django.urls import include, path
from django.views.generic import RedirectView from django.views.generic import RedirectView
@ -70,18 +69,4 @@ urlpatterns = [
), ),
), ),
path("", RedirectView.as_view(pattern_name="frontend:profile"), name="index"), 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"),
] ]

View file

@ -6,7 +6,7 @@ from django.urls import path
from django.urls.conf import include from django.urls.conf import include
from django.utils.translation import gettext_lazy as _ 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_title = _("Servala Admin")
admin.site.site_header = _("Servala Management") admin.site.site_header = _("Servala Management")
@ -26,6 +26,21 @@ urlpatterns = [
if settings.DEBUG: if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_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 # Custom error handlers
handler404 = "servala.frontend.views.custom_404" handler404 = "servala.frontend.views.custom_404"