1
0
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:
Tom Forbes
2018-11-22 03:58:43 +00:00
committed by Tim Graham
parent 5a71bd7f9d
commit 31408446b3
3 changed files with 10 additions and 2 deletions

View File

@@ -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):