> Den 03/08/2015 kl. 08.50 skrev [email protected]: > > Hello Django community. > I have two Django models Foo and Bar that have a ManyToMany relation: > > Class Foo(models.model): > > ... > > bars = models.ManyToManyField('Bar', related_name='foos') > somewhere in the code, i do direct assignment to replace the relation with a > new list: > > foo_object.bars = [bar_object_list]
You can't do that, AFAIK. You need to do: foo_object.bars.clear() foo_object.bars.add(*bar_object_list) Erik -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/C137F257-7E3B-4C68-98B7-BC540272315C%40cederstrand.dk. For more options, visit https://groups.google.com/d/optout.

