Fixed #27800 -- Fixed QuerySet.annotate(Length(...)).distinct() crash.

This commit is contained in:
Lex Berezhny 2017-01-31 18:45:55 -05:00 committed by Tim Graham
parent 84126f2789
commit ac5f886c56
3 changed files with 13 additions and 2 deletions

View file

@ -1329,7 +1329,12 @@ class Query:
"querying. If it is a GenericForeignKey, consider "
"adding a GenericRelation." % name
)
model = field.model._meta.concrete_model
try:
model = field.model._meta.concrete_model
except AttributeError:
# QuerySet.annotate() may introduce fields that aren't
# attached to a model.
model = None
else:
# We didn't find the current field, so move position back
# one step.