hmarr/mongoengine — Issue #434: Query Ref->List->Ref returns nothing
Author: danaki
Created: 2012-02-22 17:31:54+00:00
State: open

An example:

from mongoengine import Document, connect
from mongoengine.fields import *

connect('test')

class Tag(Document):
title = StringField()

class Resume(Document):
title = StringField()
tags = ListField(ReferenceField(Tag))

class Employee(Document):
resume = ReferenceField(Resume)

tag1 = Tag(title="tag1")
tag1.save()
tag2 = Tag(title="tag2")
tag2.save()
resume = Resume(title="Resume", tags=[tag1, tag2])
resume.save()
man = Employee(resume=resume)
man.save()

print Employee.objects.filter(resume__tags=tag1)

Gives empty list, I'm not sure I'm doing everything right. Or if this possible at all?