mirror of
https://github.com/jazzband/django-auditlog.git
synced 2026-03-16 22:20:26 +00:00
The previous conditional did not work as expected, when field.choices returns an empty dict the boolean is False and the operator does not shortcircuit as expected. This causes field.base_field.choices to be evaluated which crashes as it does not exist and field.choices was supposed to be the input. The updated version fixes this bug.
This commit is contained in:
parent
2105366379
commit
a98bf9d7a5
1 changed files with 7 additions and 2 deletions
|
|
@ -259,8 +259,13 @@ class LogEntry(models.Model):
|
|||
continue
|
||||
values_display = []
|
||||
# handle choices fields and Postgres ArrayField to get human readable version
|
||||
if field.choices or hasattr(field, 'base_field') and getattr(field.base_field, 'choices', False):
|
||||
choices_dict = dict(field.choices or field.base_field.choices)
|
||||
choices_dict = None
|
||||
if hasattr(field, 'choices'):
|
||||
choices_dict = dict(field.choices)
|
||||
elif hasattr(field, 'base_field') and getattr(field.base_field, 'choices', False):
|
||||
choices_dict = dict(field.base_field.choices)
|
||||
|
||||
if choices_dict:
|
||||
for value in values:
|
||||
try:
|
||||
value = ast.literal_eval(value)
|
||||
|
|
|
|||
Loading…
Reference in a new issue