Resolve field name to db field name when using distinct(#260, #264, #269)

This commit is contained in:
Ross Lawley
2013-04-12 14:20:44 +00:00
parent 37740dc010
commit 63edd16a92
4 changed files with 28 additions and 3 deletions

View File

@@ -1212,8 +1212,11 @@ class QuerySet(object):
.. versionchanged:: 0.5 - Fixed handling references
.. versionchanged:: 0.6 - Improved db_field refrence handling
"""
return self._dereference(self._cursor.distinct(field), 1,
name=field, instance=self._document)
try:
field = self._fields_to_dbfields([field]).pop()
finally:
return self._dereference(self._cursor.distinct(field), 1,
name=field, instance=self._document)
def only(self, *fields):
"""Load only a subset of this document's fields. ::