I'm confused, please tell me how to get the value of another Term_Implementation
field in Table.render_foo methods?
class EvensList(IncidentsTable, tables.Table):
class Meta:
model = AkpEvents
sequence = ('Term_Implementation', 'Status')
Term_Implementation = tables.DateColumn(empty_values=(),)
Status = tables.Column(empty_values=(),)
def render_Status(self, value, column, columns):
if value == 'Выполнено':
column.attrs = {'td': {'class': 'table-success'}}
elif value == 'В работе':
column.attrs = {'td': {'class': 'table-warning'}}
elif columns['Term_Implementation'] <= date.today():
column.attrs = {'td': {'class': 'table-danger'}}
else:
column.attrs = {'td': {'class': ''}}
return value
To solve it, you just had to use the built-in parameter of the record
function, which returns the entire object.
def render_Status(self, value, record, column):
if value == 'Выполнено':
column.attrs = {'td': {'class': 'table-success text-center align-middle'}}
elif value == 'В работе':
column.attrs = {'td': {'class': 'table-warning text-center align-middle'}}
elif record.Term_Implementation <= date.today():
column.attrs = {'td': {'class': 'table-danger text-center align-middle'}}
else:
column.attrs = {'td': {'class': 'text-center align-middle'}}
return value
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.