Skip to content

Commit

Permalink
Docs update for #400 (#401)
Browse files Browse the repository at this point in the history
* Non-column attributes on child class overwrite column attributes of parent class (fix #399)

* Fix and add to FAQ for #399.
  • Loading branch information
Dylan Verheul authored and jieter committed Dec 21, 2016
1 parent 8454c69 commit 7fcef7e
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions docs/pages/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ FAQ
===

Some frequently requested questions/examples. All examples assume you
import djang-tables2 like this::
import django-tables2 like this::

import django_tables2 as tables

Expand Down Expand Up @@ -97,4 +97,28 @@ Or by creating a custom column::
Documentation: :ref:`column-footers`

.. note ::
You table template must include a block rendering the table footer!
Your table template must include a block rendering the table footer!
Can I use inheritance to build Tables that share features?
----------------------------------------------------------

Yes, like this::

class CountryTable(tables.Table):
name = tables.Column()
language = tables.Column()

A `CountryTable` will show columns `name` and `language`.

class TouristCountryTable(CountryTable):
tourist_info = tables.Column()

A `TouristCountryTable` will show columns `name`, `language` and `tourist_info`.

Overwriting a Column attribute from the base class with anything that is not a Column will result in removing that Column from the Table. For example:

class SimpleCountryTable(CountryTable):
language = None

A `SimpleCountryTable` will only show column `name`.

0 comments on commit 7fcef7e

Please sign in to comment.