Opened 19 years ago
Closed 19 years ago
#1861 closed defect (duplicate)
Many2Many problem in AutomaticManipulator, uses premagicremoval 'set_xxx' method
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | major | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Missing magic removal change?
Revision: 2901
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.
Change History (2)
comment:1 by , 19 years ago
comment:2 by , 19 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
My first bugreport for django and I manged to create a duplicate. I'm sorry for this. Thank you coconutstudio both for your message and the patch!
(I marked this ticket as a resolved: duplicate, I hope that is the correct procedure)
See Ticket #1816 Patch