I have a table.py where I would like to change the icons for True and False values of each BooleanColumn. I know that it can be modified by the yesno paramter of BooleanColumn, but I do not know how to override the default for all BooleanColumns. Here is the Code of tables.py (aacsb, amba, equis, mba, bsc, msc and doubedegree are BooleanFields):
from django_tables2 import Column, Table
from manager.models import Partner
class PartnerTable(Table):
country_name = Column(accessor='country.name', verbose_name='Country')
region_name = Column(accessor='country.region.name', verbose_name='Region')
class Meta:
model = Partner
fields = ('name',
'country_name',
'region_name',
'website',
'aacsb',
'amba',
'equis',
'mba',
'bsc',
'msc',
'doubledegree',
)
1) So you can simply override
yesno
which default value is "✔,✘" (it is juststr
):or remove text:
2) Using
css
you can specify custom images (don't forget setyesno=','
):3) Specify some extra attrs to
span
(but don't specifyclass
!):4) If for some reasons you want change default class setting behaviour (
true
orfalse
) - you should overrideBooleanColumn
and it's methodrender
And override your field