Access related models with django-tables2

Can someone give a clear example of creating a table object using django-tables2, which selects and represents data from several related models (i.e. a relational join)? The documentation implies that this is possible, but does not say how to do it.

In regular django, the select_related () function works well, but I cannot decide how to implement this in django-tables2. I note that there are other unanswered questions on similar topics.

+3
source share
1 answer

First, select_related() not required to access related data; it exists for performance reasons. For django-tables2 you need to define accessor . Example: https://github.com/bradleyayers/django-tables2/issues/106

+3
source

All Articles