Reorder condition in get_field_value function: as many people have non-database fields and this will break their code ;)

This commit is contained in:
GreatBahram 2024-06-10 15:12:21 +02:00
parent d412b2b16a
commit 96d3906c81

View file

@ -83,7 +83,7 @@ def get_field_value(obj, field):
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 hasattr(field, "rel_class") and (field.one_to_one or field.many_to_one):
value = smart_str(
getattr(obj, field.get_attname(), None), strings_only=True
)