I have a Django table (Django Tables 2) with Link Column containing a link to another page with another table with the search form. So after click, I get from:
localhost:8000/stats/office/
to:
localhost:8000/stats/office/workers/
However, I would like to filter data by search form in the table in the second page, so it would render only clicked office (e.g. "1" as in this query):
localhost:8000/stats/office/workers/?action=submit&office=1&owner=&date_month=0&date_year=2016&submit=search
my code looks like:
#table.py
office = tables.LinkColumn('stats:office-workers', verbose_name=_(u'Pobočka'), accessor='office')
#urls.py
url(r'^stats/office/$', login_required(permission_required('view_office', raise_exception=True)(OfficeSummarizeList.as_view())), name='office'),
url(r'^stats/office/workers/$', login_required(permission_required('view_worker', raise_exception=True)(WorkerSummarizeList.as_view())), name='stats-office-workers'),
I tried many things but I was not able to pass the parameter 'office' to the view, thank you very much for your help.
Finally figured it out myself, this was enough:
table.py
office = tables.TemplateColumn('<a href="workers/?action=submit&office={{ record.office }}&submit=search">{{ record.office }}</a>')