Fix Value repr crash for missing entity

This commit is contained in:
Alishba 2025-06-03 12:11:52 +05:00
parent 9e49a84cf0
commit 6ba4a204ec

View file

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