Ticket #6707: django_m2m_set_method.diff
File django_m2m_set_method.diff, 819 bytes (added by , 17 years ago) |
---|
-
django/db/models/fields/related.py
475 475 raise AttributeError, "Manager must be accessed via instance" 476 476 477 477 manager = self.__get__(instance) 478 manager.clear() 479 manager.add(*value) 478 # another implementation to set m2m, try to affect minimal rows. 479 old_objects, target_objects = set(manager.all()), set(value) 480 add_objects = target_objects - old_objects 481 remove_objects = old_objects - target_objects 482 manager.remove(*remove_objects) 483 manager.add(*add_objects) 480 484 481 485 class ForeignKey(RelatedField, Field): 482 486 empty_strings_allowed = False