MongoEngien:method.all()引发异常:TypeError:\uu init\uuuuuu()获取了意外的关键字参数'\uu auto\u convert'

2024-03-29 12:25:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我无法使用MongoEngine从mongodb获取对象: 当我打电话的时候BaseForm.objects.all()它引发了一个异常:

...    
obj = cls(__auto_convert=False, _created=created, __only_fields=only_fields, **data)
TypeError: __init__() got an unexpected keyword argument '__auto_convert'

在mongodb中,控制台记录被正确显示。你知道吗

我的型号:

class BaseController(db.EmbeddedDocument):
    title = db.StringField(max_length=255, required=True)
    type = db.StringField(max_length=255, required=True)

    def __unicode__(self):
        return self.title

    meta = {'allow_inheritance': True}


class RadioButton(BaseController):
    def __init__(self, title):
        super(BaseController, self).__init__()
        self.title = title
        self.type = 'radiobutton'


class CheckBox(BaseController):
    def __init__(self, title):
        super(BaseController, self).__init__()
        self.title = title
        self.type = 'checkbox'


class BaseFormController(db.EmbeddedDocument):
    title = db.StringField(max_length=255, required=True)
    controllers = db.ListField(db.EmbeddedDocumentField('BaseController'))

    def __unicode__(self):
        return self.title

    meta = {'allow_inheritance': True}


class BaseForm(db.Document):
    title = db.StringField(max_length=255, required=True)
    controllers = db.ListField(db.EmbeddedDocumentField('BaseFormController'))

    def __unicode__(self):
        return self.title

    meta = {'allow_inheritance': True}

Tags: selftruedbreturntitleinitdeftype