Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

0.91-bugfixes: Fix problem parsing values from ManyToManyField with r…

…aw_id_admin. Thanks, Tom Tobin

git-svn-id: http://code.djangoproject.com/svn/django/branches/0.91-bugfixes@5647 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit e6f09afa7871e7d1b813e126841220515193c9e2 1 parent 17e9880
James Bennett authored

Showing 1 changed file with 8 additions and 0 deletions. Show diff stats Hide diff stats

  1. 8  django/core/meta/__init__.py
8  django/core/meta/__init__.py
@@ -1134,6 +1134,14 @@ def method_get_many_to_many(field_with_rel, self):
1134 1134
 # Handles setting many-to-many relationships.
1135 1135
 # Example: Poll.set_sites()
1136 1136
 def method_set_many_to_many(rel_field, self, id_list):
  1137
+    if len(id_list) == 1 and isinstance(id_list[0], basestring) and ',' in id_list[0]:
  1138
+        new_id_list = []
  1139
+        for bit in id_list[0].split(','):
  1140
+            try:
  1141
+                new_id_list.append(int(bit.strip()))
  1142
+            except ValueError:
  1143
+                continue
  1144
+        id_list = new_id_list
1137 1145
     current_ids = [getattr(obj, obj._meta.pk.attname) for obj in method_get_many_to_many(rel_field, self)]
1138 1146
     ids_to_add, ids_to_delete = dict([(i, 1) for i in id_list]), []
1139 1147
     for current_id in current_ids:

0 notes on commit e6f09af

Please sign in to comment.
Something went wrong with that request. Please try again.