improve gridfs example (properly opening file)

This commit is contained in:
Bastien Gérard 2019-12-29 14:36:50 +01:00
parent 66a0fca4ad
commit 152b51fd33

View File

@ -21,8 +21,8 @@ In the following example, a document is created to store details about animals,
marmot = Animal(genus='Marmota', family='Sciuridae') marmot = Animal(genus='Marmota', family='Sciuridae')
marmot_photo = open('marmot.jpg', 'rb') with open('marmot.jpg', 'rb') as fd:
marmot.photo.put(marmot_photo, content_type = 'image/jpeg') marmot.photo.put(fd, content_type = 'image/jpeg')
marmot.save() marmot.save()
Retrieval Retrieval