mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #12815 -- Added TemplateResponse, a lazy-evaluated Response class. Thanks to Simon Willison for the original idea, and to Mikhail Korobov and Ivan Sagalaev for their assistance, including the draft patch from Mikhail.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14850 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -1,9 +1,18 @@
|
||||
from django import http
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.template import Template
|
||||
from django.template.response import TemplateResponse
|
||||
|
||||
|
||||
def normal_view(request):
|
||||
return http.HttpResponse('OK')
|
||||
|
||||
def template_response(request):
|
||||
return TemplateResponse(request, Template('OK'))
|
||||
|
||||
def template_response_error(request):
|
||||
return TemplateResponse(request, Template('{%'))
|
||||
|
||||
def not_found(request):
|
||||
raise http.Http404()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user