Fixed #23370 -- defer() + select_related() crashed with inherited models.

This commit is contained in:
Akis Kesoglou 2014-08-29 17:01:21 +03:00 committed by Tim Graham
parent 66757fee7e
commit 6613ea6e3f
4 changed files with 46 additions and 5 deletions

View file

@ -1343,12 +1343,12 @@ def get_klass_info(klass, max_depth=0, cur_depth=0, requested=None,
init_list = []
# Build the list of fields that *haven't* been requested
for field, model in klass._meta.get_concrete_fields_with_model():
if field.name not in load_fields:
skip.add(field.attname)
elif from_parent and issubclass(from_parent, model.__class__):
if from_parent and model and issubclass(from_parent, model):
# Avoid loading fields already loaded for parent model for
# child models.
continue
elif field.name not in load_fields:
skip.add(field.attname)
else:
init_list.append(field.attname)
# Retrieve all the requested fields