From 654b293769afa068717fb099eff1e700e2bae46b Mon Sep 17 00:00:00 2001 From: jorgepastorr Date: Mon, 9 Dec 2024 11:34:09 +0100 Subject: [PATCH] custom error 500 --- .../project_template/project_name/urls.py | 4 ++- orchestra/templates/error_500.html | 34 +++++++++++++++++++ orchestra/urls.py | 3 -- orchestra/views.py | 7 ++-- 4 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 orchestra/templates/error_500.html diff --git a/orchestra/conf/project_template/project_name/urls.py b/orchestra/conf/project_template/project_name/urls.py index 3ae27421..2710e080 100644 --- a/orchestra/conf/project_template/project_name/urls.py +++ b/orchestra/conf/project_template/project_name/urls.py @@ -1,6 +1,8 @@ -from django.conf.urls import include, url +from django.conf.urls import include, url, handler500 urlpatterns = [ url(r'', include('orchestra.urls')), ] + +handler500 = 'orchestra.views.error_500' diff --git a/orchestra/templates/error_500.html b/orchestra/templates/error_500.html new file mode 100644 index 00000000..b2cdd051 --- /dev/null +++ b/orchestra/templates/error_500.html @@ -0,0 +1,34 @@ + + + + + + 500 Internal Server Error + + + +
+

Oops! Something Went Wrong

+

The error to the technicians is sent, so that they review it as soon as possible.

+

If the problem persists, you can communicate with our support team at support@pangea.org.

+
+ + \ No newline at end of file diff --git a/orchestra/urls.py b/orchestra/urls.py index 8bddc523..a2f8a2b8 100644 --- a/orchestra/urls.py +++ b/orchestra/urls.py @@ -9,11 +9,9 @@ from . import api from .utils.apps import isinstalled from orchestra.contrib.metrics.views import metrics_view - admin.autodiscover() api.autodiscover() - urlpatterns = [ # Admin url(r'^admin/', admin.site.urls), @@ -31,7 +29,6 @@ urlpatterns = [ # MUSICIAN path('panel/', include('orchestra.contrib.musician.urls')), - ] diff --git a/orchestra/views.py b/orchestra/views.py index 5b5e5652..e833d336 100644 --- a/orchestra/views.py +++ b/orchestra/views.py @@ -2,10 +2,9 @@ from django.apps import apps from django.http import Http404 from django.contrib.admin.utils import unquote from django.core.exceptions import PermissionDenied -from django.shortcuts import get_object_or_404 +from django.shortcuts import get_object_or_404, render from django.views.static import serve - def serve_private_media(request, app_label, model_name, field_name, object_id, filename): model = apps.get_model(app_label, model_name) if model is None: @@ -18,3 +17,7 @@ def serve_private_media(request, app_label, model_name, field_name, object_id, f return serve(request, field.name, document_root=field.storage.location) else: raise PermissionDenied() + + +def error_500(request): + return render(request, 'error_500.html', {}, status=500) \ No newline at end of file