mirror of
https://github.com/jazzband/django-auditlog.git
synced 2026-03-16 22:20:26 +00:00
skip using foreign key to construct and display diff of foreign key fields
This commit is contained in:
parent
57604a6069
commit
37b3ba20bd
2 changed files with 9 additions and 1 deletions
|
|
@ -106,7 +106,11 @@ def get_field_value(obj, field, use_json_for_changes=False):
|
|||
value = json.dumps(value, sort_keys=True, cls=field.encoder)
|
||||
except TypeError:
|
||||
pass
|
||||
elif (field.one_to_one or field.many_to_one) and hasattr(field, "rel_class"):
|
||||
elif (
|
||||
not settings.AUDITLOG_USE_STRING_REPRESENTATION_IN_FOREIGN_KEY_CHANGES
|
||||
and (field.one_to_one or field.many_to_one)
|
||||
and hasattr(field, "rel_class")
|
||||
):
|
||||
value = smart_str(getattr(obj, field.get_attname()), strings_only=True)
|
||||
else:
|
||||
value = getattr(obj, field.name)
|
||||
|
|
|
|||
|
|
@ -542,6 +542,10 @@ class AbstractLogEntry(models.Model):
|
|||
"""
|
||||
:return: A string representing a given FK value and the field to which it belongs
|
||||
"""
|
||||
# Return value if FK value should explicitly be interpreted as string representation
|
||||
if settings.AUDITLOG_USE_STRING_REPRESENTATION_IN_FOREIGN_KEY_CHANGES:
|
||||
return value
|
||||
|
||||
# Return "None" if the FK value is "None".
|
||||
if value == "None":
|
||||
return value
|
||||
|
|
|
|||
Loading…
Reference in a new issue