From: Bradley Ayers Date: Mon, 4 Apr 2011 05:15:09 +0000 (+1000) Subject: Merge branch 'development' X-Git-Tag: v0.4.0.beta6~3 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a19b82deacd80b3703d9809f02286c71ccfdd4b0;p=django-tables2.git Merge branch 'development' --- a19b82deacd80b3703d9809f02286c71ccfdd4b0 diff --cc docs/index.rst index bc82748,3e38c26..072f015 --- a/docs/index.rst +++ b/docs/index.rst @@@ -186,27 -212,19 +212,20 @@@ a hook that allows abitrary attributes >>> import django_tables as tables >>> class SimpleTable(tables.Table): - ... id = tables.Column(formatter=lambda x: '#%d' % x) - ... age = tables.Column(formatter=lambda x: '%d years old' % x) + ... id = tables.Column() + ... age = tables.Column() ... - >>> table = SimpleTable([{'age': 31, 'id': 10}, {'age': 34, 'id': 11}]) - >>> row = table.rows[0] - >>> for cell in row: - ... print cell + ... class Meta: + ... attrs = {'class': 'mytable'} ... - #10 - 31 years old - - As you can see, the only the value of the column is available to the formatter. - This means that **it's impossible create a formatter that incorporates other - values of the record**, e.g. a column with an ```` that uses - :func:`reverse` with the record's ``pk``. + >>> table = SimpleTable() + >>> table.as_html() + '...' - If formatters aren't powerful enough, you'll need to either :ref:`create a - Column subclass `, or to use the - :ref:`Table.render_FOO method `. + Inspired by Django's ORM, the ``class Meta:`` allows you to define extra + characteristics of a table. See :class:`Table.Meta` for details. +.. _table.render_foo: .. _table.render_foo: