1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #31382 -- Made Model.save(update_fields=...) raise ValueError on non-concrete fields.

This commit is contained in:
Pat Garcia
2020-08-11 21:05:03 -04:00
committed by Mariusz Felisiak
parent 94ea79be13
commit 8954f255bb
3 changed files with 25 additions and 5 deletions

View File

@@ -727,7 +727,7 @@ class Model(metaclass=ModelBase):
update_fields = frozenset(update_fields)
field_names = set()
for field in self._meta.fields:
for field in self._meta.concrete_fields:
if not field.primary_key:
field_names.add(field.name)
@@ -737,9 +737,11 @@ class Model(metaclass=ModelBase):
non_model_fields = update_fields.difference(field_names)
if non_model_fields:
raise ValueError("The following fields do not exist in this "
"model or are m2m fields: %s"
% ', '.join(non_model_fields))
raise ValueError(
'The following fields do not exist in this model, are m2m '
'fields, or are non-concrete fields: %s'
% ', '.join(non_model_fields)
)
# If saving to the same database, and this model is deferred, then
# automatically do an "update_fields" save on the loaded fields.