Upgrading from django-tables Version 1ΒΆ
Change your
INSTALLLED_APPSentry from"django_tables.app"to"django_tables2".Change all your import references from
django_tablestodjango_tables2.Replace all references to the old
MemoryTableandModelTableclasses with simplyTable.In your templates, load the
django_tables2template library;{% load django_tables2 %}instead of{% load tables %}.A table object is no longer iterable; rather than
for row in table, instead you now do explicitly:for row in table.rows.If you were using
row.datato access a row’s underlying data, replace it withrow.recordinstead.When declaring columns, replace the use of:
name_in_dataset = tables.Column(name="wanted_column_name")
with:
wanted_column_name = tables.Column(accessor="name_in_dataset")
When declaring columns, replace the use of:
column_to_override = tables.Column(name="wanted_column_name", data="name_in_dataset")
with:
wanted_column_name = tables.Column(accessor="name_in_dataset")
and exclude
column_to_overridevia the table meta data.When generating the link to order the column, instead of:
{% set_url_param sort=column.name_toggled %}
use:
{% querystring table.order_by_field=column.order_by_alias.next %}
Replace:
{{ column.is_ordered_reverse }} and {{ column.is_ordered_straight }}
with:
{{ column.order_by.is_descending }} and {{ column.order_by.is_ascending }}