mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add try/except around callable default
This commit is contained in:
parent
0cc999410b
commit
34a374ce9a
@ -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
|
||||
|
||||
|
@ -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):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user