#1372 closed defect (fixed)
Magic-Removal: ManyToMany Patch
Reported by: | 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)
Change History (7)
by , 19 years ago
Attachment: | manipulators.py.patch added |
---|
comment:1 by , 19 years ago
This does indeed fix the first error in #1359, though raw_id_admin=True
still errors out. Awesome work, dcurtis!
by , 19 years ago
Attachment: | related.py.patch added |
---|
comment:2 by , 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 , 19 years ago
priority: | high → normal |
---|---|
Severity: | major → 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:5 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
The Patch File!