diff options
| author | Ryan P Kilby <kilbyr@gmail.com> | 2025-06-25 22:54:50 -0700 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2025-09-04 12:15:45 -0400 |
| commit | bad03eb108b029dad70cbd997f1fef221da3e415 (patch) | |
| tree | e446cd695bada7986c5b9b5c4a44bbdf0759677e /django/db/models/sql | |
| parent | 11c2c9ac17db1c04c6de302167d4b0a5539c90fd (diff) | |
Fixed #36481 -- Fixed QuerySet.update concrete fields check.
FieldError is now emitted for invalid update calls involving reverse
relations, where previously they failed with AttributeError.
Diffstat (limited to 'django/db/models/sql')
| -rw-r--r-- | django/db/models/sql/subqueries.py | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/django/db/models/sql/subqueries.py b/django/db/models/sql/subqueries.py index 2705114a54..9936f7ff42 100644 --- a/django/db/models/sql/subqueries.py +++ b/django/db/models/sql/subqueries.py @@ -87,15 +87,12 @@ class UpdateQuery(Query): values_seq = [] for name, val in values.items(): field = self.get_meta().get_field(name) - direct = ( - not (field.auto_created and not field.concrete) or not field.concrete - ) model = field.model._meta.concrete_model if field.name == "pk" and model._meta.is_composite_pk: raise FieldError( "Composite primary key fields must be updated individually." ) - if not direct or (field.is_relation and field.many_to_many): + if not field.concrete or (field.is_relation and field.many_to_many): raise FieldError( "Cannot update model field %r (only non-relations and " "foreign keys permitted)." % field |
