mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Add missing imports and models to the examples in the view layer documentation
This commit is contained in:
@@ -215,6 +215,7 @@ re-rendered, you can re-evaluate the rendered content, and assign
|
||||
the content of the response manually::
|
||||
|
||||
# Set up a rendered TemplateResponse
|
||||
>>> from django.template.response import TemplateResponse
|
||||
>>> t = TemplateResponse(request, 'original.html', {})
|
||||
>>> t.render()
|
||||
>>> print(t.content)
|
||||
@@ -256,6 +257,8 @@ To define a post-render callback, just define a function that takes
|
||||
a single argument -- response -- and register that function with
|
||||
the template response::
|
||||
|
||||
from django.template.response import TemplateResponse
|
||||
|
||||
def my_render_callback(response):
|
||||
# Do content-sensitive processing
|
||||
do_post_processing()
|
||||
|
||||
Reference in New Issue
Block a user