python - get image from image.files with objectid -


i have problem mongoengine. objectid of image in image.files collection. how image in django, image.files.objects(pk=objectid).first()? there apis this?

you can query grid_id , return matching document so:

class testimage(document):      image = imagefield()  testimage.drop_collection()  t = testimage() t.image1.put(open(test_image_path, 'rb')) t.save()  test = testimage.objects.first() grid_id = test.image1.grid_id  self.assertequal(1, testimage.objects(image1=grid_id).count()) 

Comments