countries = [
{'name': 'Australia', 'population': 21, 'tz': 'UTC +10', 'visits': 1},
- {'name': 'Germany', 'population', 81, 'tz': 'UTC +1', 'visits': 2},
+ {'name': 'Germany', 'population': 81, 'tz': 'UTC +1', 'visits': 2},
{'name': 'Mexico', 'population': 107, 'tz': 'UTC -6', 'visits': 0},
]
def home(request):
table = CountryTable(countries)
return render_to_response('home.html', {'table': table},
- context_instances=RequestContext(request))
+ context_instance=RequestContext(request))
In your template, the easiest way to :term:`render` the table is via the
:meth:`~django_tables.tables.Table.as_html` method:
class SimpleTable(tables.Table):
name = tables.Column()
-
+
class Meta:
order_by = 'name'
class SimpleTable(tables.Table):
name = tables.Column()
-
+
table = SimpleTable(..., order_by='name')
Finally the attribute method overrides both of the previous approaches.
class SimpleTable(tables.Table):
name = tables.Column()
-
+
table = SimpleTable(...)
table.order_by = 'name'
class SimpleTable(tables.Table):
name = tables.Column()
-
+
class Meta:
sortable = False