From f9158b640f420812b14012e2ff54732f7f4a5616 Mon Sep 17 00:00:00 2001 From: Viktor Date: Fri, 1 Oct 2021 14:47:51 +0200 Subject: [PATCH] Return None if attribute choices doesn't exist Related to #273 and #293 Very minimal change that should have no impact on the code other than making sure iterated fields have a .choices attribute. --- auditlog/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auditlog/models.py b/auditlog/models.py index 8c4a73c..5192db2 100644 --- a/auditlog/models.py +++ b/auditlog/models.py @@ -310,7 +310,7 @@ class LogEntry(models.Model): values_display = [] # handle choices fields and Postgres ArrayField to get human readable version choices_dict = None - if getattr(field, "choices") and len(field.choices) > 0: + if getattr(field, "choices", None) and len(field.choices) > 0: choices_dict = dict(field.choices) if ( hasattr(field, "base_field")