Skip to content

Commit fdeec85

Browse files
omadbradleyayers
authored andcommitted
Examples use render() instead of render_to_response()
Django >= 1.3 is required now, so can use the nicer shortcuts.
1 parent 24e5808 commit fdeec85

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

docs/index.rst

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ Now instantiate the table and pass in the data, then pass it to a template:
5959
6060
def home(request):
6161
table = CountryTable(countries)
62-
return render_to_response('home.html', {'table': table},
63-
context_instance=RequestContext(request))
62+
return render(request, 'home.html', {'table': table})
6463
6564
Render the table in the template using the built-in template tag.
6665

@@ -96,8 +95,7 @@ To enable ordering and pagination, use a ``RequestConfig`` object in the view:
9695
def home(request):
9796
table = CountryTable(countries)
9897
RequestConfig(request).configure(table)
99-
return render_to_response('home.html', {'table': table},
100-
context_instance=RequestContext(request))
98+
return render(request, 'home.html', {'table': table})
10199
102100
103101
See :ref:`ordering`, and :ref:`pagination` for more information.
@@ -295,8 +293,7 @@ pass in the current page number, e.g.
295293
def people_listing(request):
296294
table = PeopleTable(Person.objects.all())
297295
table.paginate(page=request.GET.get('page', 1), per_page=25)
298-
return render_to_response('people_listing.html', {'table': table},
299-
context_instance=RequestContext(request))
296+
return render(request, 'people_listing.html', {'table': table})
300297
301298
If you're using ``RequestConfig``, pass pagination options to the constructor,
302299
e.g.:
@@ -306,8 +303,7 @@ e.g.:
306303
def people_listing(request):
307304
table = PeopleTable(Person.objects.all())
308305
RequestConfig(request, paginate={"per_page": 25}).configure(table)
309-
return render_to_response('people_listing.html', {'table': table},
310-
context_instance=RequestContext(request))
306+
return render(request, 'people_listing.html', {'table': table})
311307
312308
.. _custom-rendering:
313309

@@ -427,9 +423,8 @@ fields with a table-specific name. e.g.
427423
table2 = PeopleTable(Person.objects.all(), prefix="2-") # prefix specified
428424
config.configure(table1)
429425
config.configure(table2)
430-
return render_to_response("people_listing.html",
431-
{"table1": table1, "table2": table2},
432-
context_instance=RequestContext(request))
426+
return render(request, "people_listing.html",
427+
{"table1": table1, "table2": table2})
433428
434429
.. _column-attributes:
435430

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy