Code

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#1372 closed defect (fixed)

Magic-Removal: ManyToMany Patch

Reported by: donald-curtis@… Owned by: adrian
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: UI/UX:

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@… 8 years ago.
The Patch File!
related.py.patch (1.0 KB) - added by matt 8 years ago.

Download all attachments as: .zip

Change History (7)

Changed 8 years ago by donald-curtis@…

The Patch File!

comment:1 Changed 8 years ago by matt

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

Changed 8 years ago by matt

comment:2 Changed 8 years ago by matt

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 Changed 8 years ago by lukeplant

  • priority changed from high to normal
  • Severity changed from major to normal

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 Changed 8 years ago by Christopher Lenz <cmlenz@…>

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

comment:5 Changed 8 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.