Using djang-tables2 custom table as:
tables.py:
import django_tables2 as tables
from django_tables2.utils import A
from .models import Person
class PersonTable(tables.Table):
view_column = tables.LinkColumn('person:pessoas_detail', args=[A('pk')])
class Meta:
model = Person
views.py:
from .models import Person
class ListView(SingleTableView):
model = Person
table_class = PersonTable
I need to check permission FOO on the view_column. Because, view_column is a class attribute, I cannot use a decorator as @permission_required.
Probably I could call something other than tables.LinkColumn to test the permission and then return the column. However, in order to do this, I would need to access the user object (probably from the request object), which I wouldn't have access at this point.
Is there a simpler way for doing this?
Basically the idea is to show a column only if there is permission access to it or not show at all.