mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #11811 -- Data-loss bug in queryset.update.
It's now forbidden to call queryset.update(field=instance) when instance hasn't been saved to the database ie. instance.pk is None.
This commit is contained in:
@@ -768,6 +768,8 @@ class Model(six.with_metaclass(ModelBase)):
|
||||
return getattr(self, cachename)
|
||||
|
||||
def prepare_database_save(self, unused):
|
||||
if self.pk is None:
|
||||
raise ValueError("Unsaved model instance %r cannot be used in an ORM query." % self)
|
||||
return self.pk
|
||||
|
||||
def clean(self):
|
||||
|
||||
Reference in New Issue
Block a user