Skip to content

Commit

Permalink
Reorganize the order-by doc page a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
jieter committed May 23, 2016
1 parent d6ceb2d commit ae0d67c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/pages/customizing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Customizing the table

.. toctree::
custom-data
order-by-accessors
ordering
column-attributes
column-headers-and-footers
swapping-columns
Expand Down
16 changes: 10 additions & 6 deletions docs/pages/order-by-accessors.rst → docs/pages/ordering.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
.. _order-by-accessors:

Alternative column ordering
===========================

Expand Down Expand Up @@ -28,8 +26,15 @@ exception::
>>> # will result in:
FieldError: Cannot resolve keyword 'name' into field. Choices are: first_name, family_name

To prevent this, django-tables2 needs a hint to know how to sort that column:
you need to supply an ``order_by`` argument containing a name or a tuple of the
To prevent this, django-tables2 allows two ways to specify custom ordering:
accessors and :meth:`~.order_FOO` methods.

.. _order-by-accessors:

Ordering by accessors
---------------------

You can supply an ``order_by`` argument containing a name or a tuple of the
names of the columns the database should use to sort it::

class PersonTable(tables.Table):
Expand Down Expand Up @@ -87,8 +92,7 @@ mathematical expression. In this scenario, the table needs to be able to be
ordered by the sum of both the shirts and the pants. The custom column will
have its value rendered using :ref:`table.render_FOO`.

This can be achieved like this:
::
This can be achieved like this::

# models.py
class Person(models.Model):
Expand Down

0 comments on commit ae0d67c

Please sign in to comment.