mirror of
https://github.com/django/django.git
synced 2025-10-29 08:36:09 +00:00
Fixed #29974 -- Fixed non-truthy primary key values for QuerySet.bulk_update().
This commit is contained in:
@@ -490,7 +490,7 @@ class QuerySet:
|
||||
if not fields:
|
||||
raise ValueError('Field names must be given to bulk_update().')
|
||||
objs = tuple(objs)
|
||||
if not all(obj.pk for obj in objs):
|
||||
if any(obj.pk is None for obj in objs):
|
||||
raise ValueError('All bulk_update() objects must have a primary key set.')
|
||||
fields = [self.model._meta.get_field(name) for name in fields]
|
||||
if any(not f.concrete or f.many_to_many for f in fields):
|
||||
|
||||
Reference in New Issue
Block a user