Fix Value repr crash for missing entity

This commit is contained in:
Alishba 2025-06-03 11:52:42 +05:00
parent ae06c9629b
commit e41aa04d3a

View file

@ -488,7 +488,17 @@ class Value(models.Model):
return '{}: "{}" ({})'.format(self.attribute.name, self.value, self.entity)
def __repr__(self):
return '{}: "{}" ({})'.format(self.attribute.name, self.value, self.entity.pk)
entity_pk = None
if self.entity is not None:
try:
entity_pk = self.entity.pk
except AttributeError:
entity_pk = None
return '{}: "{}" ({})'.format(
getattr(self.attribute, 'name', None),
self.value,
entity_pk,
)
class Entity(object):