0
我有一個mongoengine的問題。我在image.files集合中獲得了一幅圖像的objectid。我怎麼能在django中獲得圖像,就像image.files.objects(pk = objectid).first()? 這是否有任何apis?從objctid的image.files中獲取圖像
我有一個mongoengine的問題。我在image.files集合中獲得了一幅圖像的objectid。我怎麼能在django中獲得圖像,就像image.files.objects(pk = objectid).first()? 這是否有任何apis?從objctid的image.files中獲取圖像
您可以直接查詢grid_id
,並返回像匹配的文檔,以便:
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())