Opened 19 years ago

Closed 19 years ago

Last modified 18 years ago

#1372 closed defect (fixed)

Magic-Removal: ManyToMany Patch

Reported by: donald-curtis@… Owned by: Adrian Holovaty
Component: Core (Other) Version: magic-removal
Severity: normal 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

Index: manipulators.py
===================================================================
--- manipulators.py (revision 2330)
+++ manipulators.py (working copy)
@@ -120,7 +120,11 @@

new_vals = new_data.get(f.name, ())

else:

new_vals = new_data.getlist(f.name)

  • was_changed = getattr(new_object, 'set_%s' % f.name)(new_vals)

+ was_changed = getattr(new_object, f.name).clear()
+ for n in new_vals:
+ m = f.rel.to.objects.get(pk=n)
+ getattr(new_object, f.name).add(m)
+ # was_changed = getattr(new_object, 'set_%s' % f.name)(new_vals)

if self.change and was_changed:

self.fields_changed.append(f.verbose_name)

Attachments (2)

manipulators.py.patch (852 bytes ) - added by donald-curtis@… 19 years ago.
The Patch File!
related.py.patch (1.0 KB ) - added by matt 19 years ago.

Download all attachments as: .zip

Change History (7)

by donald-curtis@…, 19 years ago

Attachment: manipulators.py.patch added

The Patch File!

comment:1 by matt, 19 years ago

This does indeed fix the first error in #1359, though raw_id_admin=True still errors out. Awesome work, dcurtis!

by matt, 19 years ago

Attachment: related.py.patch added

comment:2 by matt, 19 years ago

The above patch, related.py.patch fixes the situation where raw_id_admin=True . This patch along with dcurtis' fixes both problems in #1359.

comment:3 by Luke Plant, 19 years ago

priority: highnormal
Severity: majornormal

The patches don't take account of the 'was_changed' variable. The return value of .clear() isn't actually defined yet, and it wouldn't be enough anyway - a bit more work is needed on this. (I have already noted the issues in a thread on django-dev: http://groups.google.com/group/django-developers/browse_frm/thread/701f1981d94e150f/5fc281a6452295b5#5fc281a6452295b5 )

comment:4 by Christopher Lenz <cmlenz@…>, 19 years ago

I've marked #1386 as a duplicate of this ticket.

comment:5 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: newclosed

(In [2374]) magic-removal: Fixed #1372 -- Got many-to-many fields working in manipulators

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