I've discovered a potential bug when implementing Bi-Directional relationships + reverse_delete_rule.
Here is the code that work:
from mongoengine import *
class Foo(Document):
bar = ReferenceField('Bar')
class Bar(Document):
foo = ReferenceField(Foo)
Here is the code that NOT work:
from mongoengine import *
class Foo(Document):
bar = ReferenceField('Bar', reverse_delete_rule=NULLIFY)
class Bar(Document):
foo = ReferenceField(Foo, reverse_delete_rule=NULLIFY)
Hi something like this should work:
class Bar(Document):
content = StringField()
foo = ReferenceField('Foo')
class Foo(Document):
content = StringField()
bar = ReferenceField(Bar)
Bar.register_delete_rule(Foo, 'bar', NULLIFY)
Foo.register_delete_rule(Bar, 'foo', NULLIFY)
I've update the docs
Most helpful comment
Hi something like this should work:
I've update the docs