Commits

Waldemar Kornewald  committed f4005f1

fixed bug in RedirectMiddleware and added an http 500 error view that provides a request context

  • Participants
  • Parent commits 0534783

Comments (0)

Files changed (2)

File errorviews.py

+from django import http
+from django.template import Context, RequestContext, loader
+
+def server_error(request, template_name='500.html'):
+    """
+    500 error handler.
+
+    Templates: `500.html`
+    Context:
+        request_path
+            The path of the requested URL (e.g., '/app/pages/bad_page/')
+    """
+    t = loader.get_template(template_name) # You need to create a 500.html template.
+    return http.HttpResponseServerError(t.render(RequestContext(request, {'request_path': request.path})))

File middleware.py

 from django.conf import settings
+from django.http import HttpResponseRedirect
 from django.utils.cache import patch_cache_control
 
 LOGIN_REQUIRED_PREFIXES = getattr(settings, 'LOGIN_REQUIRED_PREFIXES', ())