Ticket #13022: ticket13022.diff
File ticket13022.diff, 1.4 KB (added by , 15 years ago) |
---|
-
db/models/fields/related.py
631 631 raise AttributeError("Cannot set values on a ManyToManyField which specifies an intermediary model. Use %s.%s's Manager instead." % (opts.app_label, opts.object_name)) 632 632 633 633 manager = self.__get__(instance) 634 manager.clear() 635 manager.add(*value) 634 new_pks = set([v.pk for v in value]) 635 old_pks = set([v.pk for v in manager.all()]) 636 tb_added = new_pks-old_pks 637 tb_removed = old_pks-new_pks 638 manager.remove(*tb_removed) 639 manager.add(*tb_added) 636 640 637 641 638 642 class ReverseManyRelatedObjectsDescriptor(object): … … 683 687 raise AttributeError("Cannot set values on a ManyToManyField which specifies an intermediary model. Use %s.%s's Manager instead." % (opts.app_label, opts.object_name)) 684 688 685 689 manager = self.__get__(instance) 686 manager.clear() 687 manager.add(*value) 690 new_pks = set([v.pk for v in value]) 691 old_pks = set([v.pk for v in manager.all()]) 692 tb_added = new_pks-old_pks 693 tb_removed = old_pks-new_pks 694 manager.remove(*tb_removed) 695 manager.add(*tb_added) 688 696 689 697 class ManyToOneRel(object): 690 698 def __init__(self, to, field_name, related_name=None,