Skip to content

Commit

Permalink
Documentation: Added upgrade instructions from django-tables.
Browse files Browse the repository at this point in the history
  • Loading branch information
miracle2k committed Aug 2, 2011
1 parent 106a8c7 commit 6d69f49
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1235,3 +1235,76 @@ Glossary
table data
An interable of :term:`records <record>` that
:class:`~django_tables2.tables.Table` uses to populate its rows.


Upgrading from django-tables Version 1
======================================

- Change your ``INSTALLLED_APPS`` entry from ``django_tables.app`` to
``django_tables2``.

- Change all your import references from ``django_tables`` to
``django_tables2``.

- Replace all references to the old ``MemoryTable`` and ``ModelTable``
classes with simply ``Table``.

- In your templates, load the ``django_tables2`` template 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.data`` to access a row's underlying data,
replace it with ``row.record`` instead.

- 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_override`` via the table meta data.

- When rendering columns, change ``{{ column }}`` to ``{{ column.header }}``.

- When generating the link to sort the column, instead of:

.. code-block:: django
{% set_url_param sort=column.name_toggled %}
use:

.. code-block:: django
{% if column.order_by %}
{% set_url_param sort=column.order_by.opposite %}
{% else %}
{% set_url_param sort=column.name %}
{% endif %}
You might want to use ``{% spaceless %}`` to make it more readable.

- Replace:

.. code-block:: django
{{ column.is_ordered_reverse }} and {{ column.is_ordered_straight }}
with:

.. code-block:: django
{{ column.order_by.is_descending }} and {{ column.order_by.is_ascending }}

0 comments on commit 6d69f49

Please sign in to comment.