Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit 2d6095ea5e0d7c7cd8be16b02d17b5018642e3c2 1 parent 069a885
Russell Keith-Magee freakboy3742 authored
Showing with 4 additions and 6 deletions.
  1. +1 −0  AUTHORS
  2. +3 −6 django/db/models/fields/related.py
1  AUTHORS
View
@@ -123,6 +123,7 @@ answer newbie questions, and generally made Django that much better:
Jason McBrayer <http://www.carcosa.net/jason/>
mccutchen@gmail.com
michael.mcewan@gmail.com
+ mitakummaa@gmail.com
mmarshall
Eric Moritz <http://eric.themoritzfamily.com/>
Robin Munn <http://www.geekforgod.com/>
9 django/db/models/fields/related.py
View
@@ -256,8 +256,7 @@ def __set__(self, instance, value):
# 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 @@ def __set__(self, instance, value):
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 @@ def __set__(self, instance, value):
manager = self.__get__(instance)
manager.clear()
- for obj in value:
- manager.add(obj)
+ manager.add(*value)
class ForeignKey(RelatedField, Field):
empty_strings_allowed = False
Please sign in to comment.
Something went wrong with that request. Please try again.