我正在使用Flask + mongoengine来创建一个Web应用程序。这是我的模型的一部分
class Order(Document):
placed_on=DateTimeField(required=True)
order_id = SequenceField()
status = StringField(default="Request Received")
cart = ListField(DictField())
userMobile = StringField(required=True)
userEmail = StringField(required=True)
address = ReferenceField(Address)
sheet_id = IntField(default=0)
remarks = StringField(default="")
meta = {'allow_inheritance': True}
class ConfirmedOrder(Order):
delivery_slot_start = DateTimeField()
delivery_slot_end = DateTimeField()
meta = {'allow_inheritance': True}
我有一个Order类的实例作为订单。我现在想将它转换为ConfirmedOrder。这是我用于转换的代码
try:
order = Order.objects.get(id=order_id)
cOrder = ConfirmedOrder(**order.to_mongo())
cOrder.delivery_slot_start = timest
cOrder.delivery_slot_end = timend
cOrder.save();
except Exception as e:
print e
我但是,得到这个错误:
The field '_id' does not exist on the document 'Order.ConfirmedOrder'