Fixed an HTTP 500 error when the attached file does not exist
parent
8033c3b31c
commit
2036ba4951
|
@ -22,8 +22,11 @@ class AttachmentSerializer(serializers.ModelSerializer):
|
|||
|
||||
def get_size(self, obj):
|
||||
if obj.attached_file:
|
||||
try:
|
||||
return obj.attached_file.size
|
||||
return None
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
return 0
|
||||
|
||||
|
||||
# User Stories common serializers
|
||||
|
|
Loading…
Reference in New Issue