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.
This commit is contained in:
Viktor 2021-10-01 14:47:51 +02:00 committed by GitHub
parent e2913da1bb
commit f9158b640f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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")