[Django]-Django-tables2 exclude & field not working

8👍

You must make sure exclude is a tuple (or list), and not a string. If you use parenthesis with one string, the resulting value will be a string, not a tuple like you might expect:

Python 3.5.2 (default, Nov 17 2016, 17:05:23) 
>>> ('foo')
'foo'
>>> ('foo', )
('foo',)
>>> 

In your case, you should add a comma after 'index' like this:

class slsummTable(tables.Table):

    class Meta:
        model = DailyslSumm
        exclude = ('index', )  # <- note the extra comma here
👤Jieter

Leave a comment