@@ -59,8 +59,7 @@ Now instantiate the table and pass in the data, then pass it to a template:
59
59
60
60
def home (request ):
61
61
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})
64
63
65
64
Render the table in the template using the built-in template tag.
66
65
@@ -96,8 +95,7 @@ To enable ordering and pagination, use a ``RequestConfig`` object in the view:
96
95
def home (request ):
97
96
table = CountryTable(countries)
98
97
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})
101
99
102
100
103
101
See :ref: `ordering `, and :ref: `pagination ` for more information.
@@ -295,8 +293,7 @@ pass in the current page number, e.g.
295
293
def people_listing (request ):
296
294
table = PeopleTable(Person.objects.all())
297
295
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})
300
297
301
298
If you're using ``RequestConfig ``, pass pagination options to the constructor,
302
299
e.g.:
@@ -306,8 +303,7 @@ e.g.:
306
303
def people_listing (request ):
307
304
table = PeopleTable(Person.objects.all())
308
305
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})
311
307
312
308
.. _custom-rendering :
313
309
@@ -427,9 +423,8 @@ fields with a table-specific name. e.g.
427
423
table2 = PeopleTable(Person.objects.all(), prefix = " 2-" ) # prefix specified
428
424
config.configure(table1)
429
425
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})
433
428
434
429
.. _column-attributes :
435
430
0 commit comments