Fixed an HTTP 500 error when the attached file does not exist

remotes/origin/enhancement/email-actions
David Barragán Merino 2013-11-05 12:20:23 +01:00
parent 8033c3b31c
commit 2036ba4951
1 changed files with 5 additions and 2 deletions

View File

@ -22,8 +22,11 @@ class AttachmentSerializer(serializers.ModelSerializer):
def get_size(self, obj):
if obj.attached_file:
return obj.attached_file.size
return None
try:
return obj.attached_file.size
except FileNotFoundError:
pass
return 0
# User Stories common serializers