Add try/except around callable default

This commit is contained in:
Oliver Walters 2021-06-27 01:18:09 +10:00
parent 0cc999410b
commit 34a374ce9a
2 changed files with 8 additions and 4 deletions

View File

@ -70,7 +70,10 @@ class InvenTreeModelSerializer(serializers.ModelSerializer):
# Account for callable functions
if callable(value):
value = value()
try:
value = value()
except:
continue
data[field_name] = value
@ -98,7 +101,10 @@ class InvenTreeModelSerializer(serializers.ModelSerializer):
# Account for callable functions
if callable(value):
value = value()
try:
value = value()
except:
continue
initials[field_name] = value

View File

@ -603,8 +603,6 @@ class PartDetailTests(InvenTreeAPITestCase):
# And now check that the image has been set
p = Part.objects.get(pk=pk)
print("Image:", p.image.file)
class PartAPIAggregationTest(InvenTreeAPITestCase):
"""