Opened 13 years ago

Closed 13 years ago

#1861 closed defect (duplicate)

Many2Many problem in AutomaticManipulator, uses premagicremoval 'set_xxx' method

Reported by: mattias@… Owned by: Adrian Holovaty
Component: contrib.admin Version: master
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


Missing magic removal change?

Revision: 2901

Exception Value: 'Package' object has no attribute 'set_labels'
Exception Location: <mypath>/django/db/models/ 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.

# Save many-to-many objects.
for f in related.opts.many_to_many:
    if child_follow.get(, None) and not f.rel.edit_inline:
        was_changed = getattr(new_rel_obj, 'set_%s' %[f.attname])

I don't quite grasp the code in so I'm not able to supply a patch.

Change History (2)

comment:1 Changed 13 years ago by coconutstudio@…

See Ticket #1816 Patch

comment:2 Changed 13 years ago by mattias@…

Resolution: duplicate
Status: newclosed

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)

Note: See TracTickets for help on using tickets.
Back to Top