summaryrefslogtreecommitdiff
path: root/docs/topics/forms/modelforms.txt
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-12-22 10:21:24 -0500
committerTim Graham <timograham@gmail.com>2015-12-23 10:50:55 -0500
commitd162b0bcd8367cc2ddf1ccd613a80a2e82c3b262 (patch)
treedf67425e80a07513cdf654d4ea1afc90e9f190d0 /docs/topics/forms/modelforms.txt
parent2f205e073bbcafc3e2708a0d9c70e0727f9916fb (diff)
[1.9.x] Fixed #25969 -- Replaced render_to_response() with render() in docs examples.
Backport of 4d83b0163e15f8352fd17fa121e929842ff2b686 from master
Diffstat (limited to 'docs/topics/forms/modelforms.txt')
-rw-r--r--docs/topics/forms/modelforms.txt16
1 files changed, 5 insertions, 11 deletions
diff --git a/docs/topics/forms/modelforms.txt b/docs/topics/forms/modelforms.txt
index 882478fc2a..67b8ba510d 100644
--- a/docs/topics/forms/modelforms.txt
+++ b/docs/topics/forms/modelforms.txt
@@ -954,7 +954,7 @@ Model formsets are very similar to formsets. Let's say we want to present a
formset to edit ``Author`` model instances::
from django.forms import modelformset_factory
- from django.shortcuts import render_to_response
+ from django.shortcuts import render
from myapp.models import Author
def manage_authors(request):
@@ -966,9 +966,7 @@ formset to edit ``Author`` model instances::
# do something.
else:
formset = AuthorFormSet()
- return render_to_response("manage_authors.html", {
- "formset": formset,
- })
+ return render(request, 'manage_authors.html', {'formset': formset})
As you can see, the view logic of a model formset isn't drastically different
than that of a "normal" formset. The only difference is that we call
@@ -1022,7 +1020,7 @@ As stated earlier, you can override the default queryset used by the model
formset::
from django.forms import modelformset_factory
- from django.shortcuts import render_to_response
+ from django.shortcuts import render
from myapp.models import Author
def manage_authors(request):
@@ -1035,9 +1033,7 @@ formset::
# Do something.
else:
formset = AuthorFormSet(queryset=Author.objects.filter(name__startswith='O'))
- return render_to_response("manage_authors.html", {
- "formset": formset,
- })
+ return render(request, 'manage_authors.html", {'formset': formset})
Note that we pass the ``queryset`` argument in both the ``POST`` and ``GET``
cases in this example.
@@ -1213,9 +1209,7 @@ of a model. Here's how you can do that::
return HttpResponseRedirect(author.get_absolute_url())
else:
formset = BookInlineFormSet(instance=author)
- return render_to_response("manage_books.html", {
- "formset": formset,
- })
+ return render(request, 'manage_books.html', {'formset': formset})
Notice how we pass ``instance`` in both the ``POST`` and ``GET`` cases.