Ticket #2579: fix_raw_id_admin_m2m.2.patch
File fix_raw_id_admin_m2m.2.patch, 1.2 KB (added by , 18 years ago) |
---|
-
django/db/models/manipulators.py
old new 116 116 for f in self.opts.many_to_many: 117 117 if self.follow.get(f.name, None): 118 118 if not f.rel.edit_inline: 119 120 # First, clear the existing values. 121 rel_manager = getattr(new_object, f.name) 122 rel_manager.clear() 123 119 124 if f.rel.raw_id_admin: 120 125 new_vals = new_data.get(f.name, ()) 126 # Not handling 'empty' raw_id_admin fields properly 127 # If nothing was entered, skip the rel manager add 128 if len(new_vals) == 1 and '' == new_vals[0]: 129 continue 121 130 else: 122 131 new_vals = new_data.getlist(f.name) 123 # First, clear the existing values.124 rel_manager = getattr(new_object, f.name)125 rel_manager.clear()126 132 # Then, set the new values. 127 133 for n in new_vals: 128 134 rel_manager.add(f.rel.to._default_manager.get(pk=n))