hmarr/mongoengine — Issue #373: Multi directional references
Author: rozza
Created: 2011-11-29 10:04:03+00:00
State: open

Highlighted in #318

```python

def test_multidirectional_generic_references(self):

class Asset(db.Document):
name = db.StringField(max_length=250, required=True)
parent = db.GenericReferenceField(default=None)
parents = db.ListField(db.GenericReferenceField(), default=list)
children = db.ListField(db.GenericReferenceField(), default=list)

Asset.drop_collection()

root = Asset(name='', path="/", title="Site Root")
root.save()

company = Asset(name='company', title='Company', parent=root, parents=[root])
company.save()

root.children = [company]
root.save()

```