From 91fce675a453764cb233e53c0460826600c828fa Mon Sep 17 00:00:00 2001 From: Loic Bistuer Date: Fri, 29 Nov 2013 03:01:08 +0700 Subject: [PATCH] Use 'update_fields' in RelatedManager.clear() when bulk=False. Thanks Simon Charette for the suggestion. Refs #21169. --- django/db/models/fields/related.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index 4a945e0f452..1466270e5f0 100644 --- a/django/db/models/fields/related.py +++ b/django/db/models/fields/related.py @@ -492,7 +492,7 @@ def create_foreign_related_manager(superclass, rel_field, rel_model): with transaction.commit_on_success_unless_managed(using=db, savepoint=False): for obj in queryset: setattr(obj, rel_field.name, None) - obj.save() + obj.save(update_fields=[rel_field.name]) _clear.alters_data = True return RelatedManager