bradleyayers/django-tables2 — pull request #206 by mbertheau (2014-08-11 14:02:50+00:00)
Title: Add MultiTableMixin to support >1 tables in one view

This in incomplete because it doesn't support different pagination or ordering per table. It's here in case someone else wants to build a more complete solution based on that. Maybe I get around to doing it in the future :)

Use like this:

class CompanyUpdateView(MultiTableMixin, UpdateView):
class PlaceOfBusinessTable:
table_class = PlaceOfBusinessTable
context_table_name = "place_of_business_table"

def get_table_data(self, view):
return view.object.placeofbusiness_set.all()

class SubdomainTable:
table_class = SubdomainTable
context_table_name = "subdomain_table"

def get_table_data(self, view):
return Subdomain.objects.filter(placeofbusiness__company=view.object).distinct()

tables = [PlaceOfBusinessTable, SubdomainTable]