hmarr/mongoengine — Issue #356: distinct() on ReferenceField is returning list of DBRef
Author: joeshaw
Created: 2011-11-11 21:30:56+00:00
State: open

If you call `distinct()` for a `ReferenceField`, it returns a list of `DBRef` rather than dereferencing the objects.

class Foo(Document):
bar = ReferenceField("Bar")

class Bar(Document):
text = StringField()

bar = Bar(text="hi")
bar.save()

foo = Foo(bar=bar)
foo.save()

print Foo.objects.distinct("bar") # -> [DBRef(u'bar', ObjectId('4ebd8d8477adbf4bfb000002'))]