我在mongoengine ORM下面的類定義:保存的ImageField mongoengine
from PIL import Image
def post(self, *args, **kwargs):
merchant = self._merchant
data = self._data
obj_data = {}
if merchant:
params = self.serialize() # I am getting params dict. NO Issues with this.
obj_data['name'] = params.get('title', None)
obj_data['description'] = params.get('description', None)
path = params.get('file_path', None)
image = Image.open(path)
print image # **
obj_data['image'] = image # this is also working fine.
obj_data['caption'] = params.get('caption', None)
obj_data['user'] = user
des = Description(**obj_data)
des.save()
print obj_data['image'] # **
print des.image # This is printing as <ImageGridFsProxy: None>
**打印obj_data [ '形象']和打印:
import mongoengine as me
class Description(me.Document):
user = me.ReferenceField(User, required=True)
name = me.StringField(required=True, max_length=50)
caption = me.StringField(required=True, max_length=80)
description = me.StringField(required=True, max_length=100)
image = me.ImageField()
在我的龍捲風網絡requesthandler的我POST方法
圖像打印如下:
<PIL.PngImagePlugin.PngImageFile image mode=1 size=290x290 at 0x7F83AE0E91B8>
但
des.image仍然沒有。
請指教我這裏有什麼問題。
在此先感謝大家。
'promo'的其他屬性呢?他們好嗎? – alexvassel
嗨alexvassel, 我已經編輯過一次。一些更正。促銷實際上是描述。致歉,請致電 。休息是好的。 – Somesh