Switch error responses to TemplateResponse calls
This commit is contained in:
parent
325660bea1
commit
ece6d66bd1
@ -2,6 +2,7 @@ from django.shortcuts import render
|
|||||||
from django.contrib.sites.models import get_current_site
|
from django.contrib.sites.models import get_current_site
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
|
from django.template.response import TemplateResponse
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
from xhtml2pdf import pisa
|
from xhtml2pdf import pisa
|
||||||
@ -39,17 +40,13 @@ def disclaimer(request):
|
|||||||
return render(request, 'basics/disclaimer.html', {})
|
return render(request, 'basics/disclaimer.html', {})
|
||||||
|
|
||||||
def notfound(request):
|
def notfound(request):
|
||||||
body = render_to_string('basics/notfound.html', {})
|
return TemplateResponse(request, 'basics/notfound.html', status = 404).render()
|
||||||
return HttpResponse(body, status_code = 404)
|
|
||||||
|
|
||||||
def serverror(request):
|
def serverror(request):
|
||||||
body = render_to_string('basics/serverror.html', {})
|
return TemplateResponse(request, 'basics/serverror.html', status = 500).render()
|
||||||
return HttpResponse(body, status_code = 500)
|
|
||||||
|
|
||||||
def forbidden(request):
|
def forbidden(request):
|
||||||
body = render_to_string('basics/forbidden.html', {})
|
return TemplateResponse(request, 'basics/forbidden.html', status = 403).render()
|
||||||
return HttpResponse(body, status_code = 403)
|
|
||||||
|
|
||||||
def badrequest(request):
|
def badrequest(request):
|
||||||
body = render_to_string('basics/badrequest.html', {})
|
return TemplateResponse(request, 'basics/badrequest.html', status = 400).render()
|
||||||
return HttpResponse(body, status_code = 400)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user