Use 'update_fields' in RelatedManager.clear() when bulk=False.

Thanks Simon Charette for the suggestion.

Refs #21169.
This commit is contained in:
Loic Bistuer 2013-11-29 03:01:08 +07:00
parent 34b8a38558
commit 91fce675a4
1 changed files with 1 additions and 1 deletions

View File

@ -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): with transaction.commit_on_success_unless_managed(using=db, savepoint=False):
for obj in queryset: for obj in queryset:
setattr(obj, rel_field.name, None) setattr(obj, rel_field.name, None)
obj.save() obj.save(update_fields=[rel_field.name])
_clear.alters_data = True _clear.alters_data = True
return RelatedManager return RelatedManager