Fixed #28838 -- Fixed Model.save() crash if the base manager annotates with a related field.

This commit is contained in:
shanghui 2018-01-14 10:58:21 +08:00 committed by Tim Graham
parent cbac11f962
commit 8dc675d90f
3 changed files with 31 additions and 1 deletions

View file

@ -701,6 +701,8 @@ class QuerySet:
"Cannot update a query once a slice has been taken."
query = self.query.chain(sql.UpdateQuery)
query.add_update_fields(values)
# Clear any annotations so that they won't be present in subqueries.
query._annotations = None
self._result_cache = None
return query.get_compiler(self.db).execute_sql(CURSOR)
_update.alters_data = True