~netlandish/django-wiki

42092ff3cb1446dab0726f6d3ed98f9b4a8aa7fc — Benjamin Bach 8 years ago 9177159
Error handling views in testproject should be updated for latest django
1 files changed, 8 insertions(+), 3 deletions(-)

M testproject/testproject/views.py
M testproject/testproject/views.py => testproject/testproject/views.py +8 -3
@@ 6,7 6,7 @@ from django.views.decorators.csrf import requires_csrf_token


@requires_csrf_token
def server_error(request, template_name='500.html'):
def server_error(request, template_name='500.html', **param_dict):
    # You need to create a 500.html template.
    t = loader.get_template(template_name)
    return HttpResponseServerError(t.render(RequestContext(


@@ 14,11 14,16 @@ def server_error(request, template_name='500.html'):
        {
            'MEDIA_URL': settings.MEDIA_URL,
            'STATIC_URL': settings.STATIC_URL,
            'request': request,
        },
    )))


def page_not_found(request, template_name='404.html'):
    response = server_error(request, template_name=template_name)
def page_not_found(request, template_name='404.html', exception=None):
    response = server_error(
        request,
        template_name=template_name,
        exception=exception
    )
    response.status_code = 404
    return response