mirror of
https://github.com/django/django.git
synced 2025-07-24 05:36:15 +00:00
Add missing imports and models to the examples in the view layer documentation
This commit is contained in:
parent
e4591debd1
commit
cd72c55d86
8 changed files with 57 additions and 2 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue