From 76a4ea0f95fc3bf46237899a39cb607e90711a45 Mon Sep 17 00:00:00 2001 From: Ryan Castner Date: Tue, 2 Jan 2018 13:12:44 -0500 Subject: [PATCH] Fix issue where base_field.choices has options but we short circuit on an empty field.choices --- src/auditlog/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/auditlog/models.py b/src/auditlog/models.py index 261fe33..d06b408 100644 --- a/src/auditlog/models.py +++ b/src/auditlog/models.py @@ -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: