diff options
| author | Pat Garcia <commonzenmedia@gmail.com> | 2020-08-11 21:05:03 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-08-12 21:13:55 +0200 |
| commit | 8954f255bbf5f4ee997fd6de62cb50fc9b5dd697 (patch) | |
| tree | 289deb388c46eb5d01aa7141bae90db6867975f1 /django | |
| parent | 94ea79be137f3cb30949bf82198e96e094f2650d (diff) | |
Fixed #31382 -- Made Model.save(update_fields=...) raise ValueError on non-concrete fields.
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/base.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/django/db/models/base.py b/django/db/models/base.py index 7c7bd2d7ee..97d1eecbc8 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -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. |
