Many2Many problem in AutomaticManipulator, uses premagicremoval 'set_xxx' method
|Reported by:||Owned by:||Adrian Holovaty|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Missing magic removal change?
Exception Value: 'Package' object has no attribute 'set_labels'
Exception Location: <mypath>/django/db/models/manipulators.py in save, line 218
Basic version of my models, the exception occurs when using the admin site.
class A(models.Model): ... class Label(models.Model): ... class Package(models.Model): labels = models.ManyToManyField(Label, blank=True, null=True, raw_id_admin=False) a = models.ForeignKey(A, edit_inline=models.STACKED)
If you read RemovingTheMagic in the wiki it says that Many-to-many related lookups has changed and doesn't use set_<name> any more but instead uses <name>.add and so on... My guess is that this is the cause of the problem.
#django/db/models/manipulators.py:215-218 # Save many-to-many objects. for f in related.opts.many_to_many: if child_follow.get(f.name, None) and not f.rel.edit_inline: was_changed = getattr(new_rel_obj, 'set_%s' % f.name)(rel_new_data[f.attname])
I don't quite grasp the code in manipulators.py so I'm not able to supply a patch.