Fixed as_pymongo to return the id (#386)
This commit is contained in:
parent
4209d61b13
commit
f34e8a0ff6
@ -4,6 +4,7 @@ Changelog
|
||||
|
||||
Changes in 0.8.3
|
||||
================
|
||||
- Fixed as_pymongo to return the id (#386)
|
||||
- Document.select_related() now respects `db_alias` (#377)
|
||||
- Reload uses shard_key if applicable (#384)
|
||||
- Dynamic fields are ordered based on creation and stored in _fields_ordered (#396)
|
||||
|
@ -1423,7 +1423,8 @@ class QuerySet(object):
|
||||
# used. If not, handle all fields.
|
||||
if not getattr(self, '__as_pymongo_fields', None):
|
||||
self.__as_pymongo_fields = []
|
||||
for field in self._loaded_fields.fields - set(['_cls', '_id']):
|
||||
|
||||
for field in self._loaded_fields.fields - set(['_cls']):
|
||||
self.__as_pymongo_fields.append(field)
|
||||
while '.' in field:
|
||||
field, _ = field.rsplit('.', 1)
|
||||
|
@ -3227,6 +3227,9 @@ class QuerySetTest(unittest.TestCase):
|
||||
User(name="Bob Dole", age=89, price=Decimal('1.11')).save()
|
||||
User(name="Barack Obama", age=51, price=Decimal('2.22')).save()
|
||||
|
||||
results = User.objects.only('id', 'name').as_pymongo()
|
||||
self.assertEqual(results[0].keys(), ['_id', 'name'])
|
||||
|
||||
users = User.objects.only('name', 'price').as_pymongo()
|
||||
results = list(users)
|
||||
self.assertTrue(isinstance(results[0], dict))
|
||||
|
Loading…
x
Reference in New Issue
Block a user