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
This commit is contained in:
Russell Keith-Magee 2006-12-20 09:59:03 +00:00
parent 069a8858ba
commit 2d6095ea5e
2 changed files with 4 additions and 6 deletions

View File

@ -123,6 +123,7 @@ answer newbie questions, and generally made Django that much better:
Jason McBrayer <http://www.carcosa.net/jason/> Jason McBrayer <http://www.carcosa.net/jason/>
mccutchen@gmail.com mccutchen@gmail.com
michael.mcewan@gmail.com michael.mcewan@gmail.com
mitakummaa@gmail.com
mmarshall mmarshall
Eric Moritz <http://eric.themoritzfamily.com/> Eric Moritz <http://eric.themoritzfamily.com/>
Robin Munn <http://www.geekforgod.com/> Robin Munn <http://www.geekforgod.com/>

View File

@ -256,8 +256,7 @@ class ForeignRelatedObjectsDescriptor(object):
# Otherwise, just move the named objects into the set. # Otherwise, just move the named objects into the set.
if self.related.field.null: if self.related.field.null:
manager.clear() manager.clear()
for obj in value: manager.add(*value)
manager.add(obj)
def create_many_related_manager(superclass): def create_many_related_manager(superclass):
"""Creates a manager that subclasses 'superclass' (which is a Manager) """Creates a manager that subclasses 'superclass' (which is a Manager)
@ -405,8 +404,7 @@ class ManyRelatedObjectsDescriptor(object):
manager = self.__get__(instance) manager = self.__get__(instance)
manager.clear() manager.clear()
for obj in value: manager.add(*value)
manager.add(obj)
class ReverseManyRelatedObjectsDescriptor(object): class ReverseManyRelatedObjectsDescriptor(object):
# This class provides the functionality that makes the related-object # This class provides the functionality that makes the related-object
@ -447,8 +445,7 @@ class ReverseManyRelatedObjectsDescriptor(object):
manager = self.__get__(instance) manager = self.__get__(instance)
manager.clear() manager.clear()
for obj in value: manager.add(*value)
manager.add(obj)
class ForeignKey(RelatedField, Field): class ForeignKey(RelatedField, Field):
empty_strings_allowed = False empty_strings_allowed = False