QuerySet.only field name translation and polymorphism fix
This commit is contained in:
parent
200e9eca92
commit
265776566e
2 changed files with 45 additions and 1 deletions
|
|
@ -456,7 +456,18 @@ class QuerySet(object):
|
|||
|
||||
:param *fields: fields to include
|
||||
"""
|
||||
self._loaded_fields = list(fields)
|
||||
self._loaded_fields = []
|
||||
for field in fields:
|
||||
if '.' in field:
|
||||
raise InvalidQueryError('Subfields cannot be used as '
|
||||
'arguments to QuerySet.only')
|
||||
# Translate field name
|
||||
field_name = QuerySet._lookup_field(self._document, field)[-1].name
|
||||
self._loaded_fields.append(field_name)
|
||||
|
||||
# _cls is needed for polymorphism
|
||||
if self._document._meta.get('allow_inheritance'):
|
||||
self._loaded_fields += ['_cls']
|
||||
return self
|
||||
|
||||
def order_by(self, *keys):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue