Mongoengine-有什么方法可以将python dict转换为要保存在mongodb中的模型对象?

时间:2019-02-17 10:57:49

标签: python-3.5 mongoengine

我的mongo引擎模型如下所示

class Device(BaseDocument):
    name = StringField(),
    ipmsType = StringField(),

我想像这样将表单请求主体转换为要保存在mongodb中的模型对象

    device_form = request.get_json()
    print("here is what i am getting", device_form)
    current_app.logger.info("Inside device route")
    device_model = Device(**device_form)

    device_model.save()

但是我收到此错误

The fields "{'name', 'ipmsType'}" do not exist on the document "Device"

0 个答案:

没有答案