Permalink
Browse files

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

Thanks Simon Charette for the suggestion.

Refs #21169.
  • Loading branch information...
1 parent 34b8a38 commit 91fce675a453764cb233e53c0460826600c828fa @loic loic committed Nov 28, 2013
Showing with 1 addition and 1 deletion.
  1. +1 −1 django/db/models/fields/related.py
View
2 django/db/models/fields/related.py
@@ -492,7 +492,7 @@ def _clear(self, queryset, bulk):
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

0 comments on commit 91fce67

Please sign in to comment.