From 2d6095ea5e0d7c7cd8be16b02d17b5018642e3c2 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Wed, 20 Dec 2006 09:59:03 +0000 Subject: [PATCH] Fixed #3142 -- Optimized the assignment of m2m and m2o relation sets. Thanks, (and well spotted!) mitakummaa@gmail.com. git-svn-id: http://code.djangoproject.com/svn/django/trunk@4231 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- AUTHORS | 1 + django/db/models/fields/related.py | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/AUTHORS b/AUTHORS index 914775fe36..645913e7c4 100644 --- a/AUTHORS +++ b/AUTHORS @@ -123,6 +123,7 @@ answer newbie questions, and generally made Django that much better: Jason McBrayer mccutchen@gmail.com michael.mcewan@gmail.com + mitakummaa@gmail.com mmarshall Eric Moritz Robin Munn diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index 6c9d7f258f..60a5b9b7b0 100644 --- a/django/db/models/fields/related.py +++ b/django/db/models/fields/related.py @@ -256,8 +256,7 @@ class ForeignRelatedObjectsDescriptor(object): # Otherwise, just move the named objects into the set. if self.related.field.null: manager.clear() - for obj in value: - manager.add(obj) + manager.add(*value) def create_many_related_manager(superclass): """Creates a manager that subclasses 'superclass' (which is a Manager) @@ -405,8 +404,7 @@ class ManyRelatedObjectsDescriptor(object): manager = self.__get__(instance) manager.clear() - for obj in value: - manager.add(obj) + manager.add(*value) class ReverseManyRelatedObjectsDescriptor(object): # This class provides the functionality that makes the related-object @@ -447,8 +445,7 @@ class ReverseManyRelatedObjectsDescriptor(object): manager = self.__get__(instance) manager.clear() - for obj in value: - manager.add(obj) + manager.add(*value) class ForeignKey(RelatedField, Field): empty_strings_allowed = False