Skip to content

Commit

Permalink
allow none for fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahesh0253 committed Jun 17, 2021
1 parent 48af1a2 commit c4ea628
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
@instance.register
class Media(Document):
file_id = fields.StrField(attribute='_id')
file_ref = fields.StrField()
file_ref = fields.StrField(allow_none=True)
file_name = fields.StrField(required=True)
file_size = fields.IntField(required=True)
file_type = fields.StrField()
mime_type = fields.StrField()
caption = fields.StrField()
file_type = fields.StrField(allow_none=True)
mime_type = fields.StrField(allow_none=True)
caption = fields.StrField(allow_none=True)

class Meta:
collection_name = COLLECTION_NAME
Expand All @@ -47,7 +47,7 @@ async def save_file(media):
file_size=media.file_size,
file_type=media.file_type,
mime_type=media.mime_type,
caption=media.caption.html if media.caption else '',
caption=media.caption.html if media.caption else None,
)
except ValidationError:
logger.exception('Error occurred while saving file in database')
Expand Down

0 comments on commit c4ea628

Please sign in to comment.