开发者

MongoEngine 0.5: RuntimeError: maximum recursion depth exceeded while calling a Python object

    >>> from mongoengine import *
    >>> connect('foo')
    >>> class Foo(Document):
    ...   bar = ListField(ReferenceField('Foo'))
    >>>开发者_如何转开发 a = Foo()
    >>> a.save()
    >>> b = Foo()
    >>> b.save()
    >>> a.bar.append(b)
    >>> a.save()
    >>> b.bar.append(a)
    >>> b.save()

Results in a "RuntimeError: maximum recursion depth exceeded while calling a Python object" in MongoEngine 0.5. How do I get around this?


this has been fixed in the dev branch - please update.


RTD --> http://mongoengine-odm.readthedocs.org/en/latest/guide/defining-documents.html#reference-fields

To add a ReferenceField that references the document being defined, use the string 'self' in place of the document class as the argument to ReferenceField‘s constructor.

Try this:

class Foo(Document):
    bar = ListField(ReferenceField('self'))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜