Fix issue where base_field.choices has options but we short circuit on an empty field.choices

This commit is contained in:
Ryan Castner 2018-01-02 13:12:44 -05:00
parent a94ca4d5fd
commit 76a4ea0f95

View file

@ -259,9 +259,9 @@ class LogEntry(models.Model):
values_display = []
# handle choices fields and Postgres ArrayField to get human readable version
choices_dict = None
if hasattr(field, 'choices'):
if hasattr(field, 'choices') and len(field.choices) > 0:
choices_dict = dict(field.choices)
elif hasattr(field, 'base_field') and getattr(field.base_field, 'choices', False):
if hasattr(field, 'base_field') and getattr(field.base_field, 'choices', False):
choices_dict = dict(field.base_field.choices)
if choices_dict: