mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #35350 -- Fixed save() with pk set on models with GeneratedFields.
Thanks Matt Hegarty for the report and Simon Charette and Natalia Bidart for the reviews.
Regression in f333e35.
This commit is contained in:
@@ -1063,12 +1063,16 @@ class Model(AltersData, metaclass=ModelBase):
|
||||
for a single table.
|
||||
"""
|
||||
meta = cls._meta
|
||||
non_pks = [f for f in meta.local_concrete_fields if not f.primary_key]
|
||||
non_pks_non_generated = [
|
||||
f
|
||||
for f in meta.local_concrete_fields
|
||||
if not f.primary_key and not f.generated
|
||||
]
|
||||
|
||||
if update_fields:
|
||||
non_pks = [
|
||||
non_pks_non_generated = [
|
||||
f
|
||||
for f in non_pks
|
||||
for f in non_pks_non_generated
|
||||
if f.name in update_fields or f.attname in update_fields
|
||||
]
|
||||
|
||||
@@ -1100,7 +1104,7 @@ class Model(AltersData, metaclass=ModelBase):
|
||||
None,
|
||||
(getattr(self, f.attname) if raw else f.pre_save(self, False)),
|
||||
)
|
||||
for f in non_pks
|
||||
for f in non_pks_non_generated
|
||||
]
|
||||
forced_update = update_fields or force_update
|
||||
updated = self._do_update(
|
||||
|
||||
Reference in New Issue
Block a user