Author: ubernostrum
Date: 2007-07-11 12:41:58 -0500 (Wed, 11 Jul 2007)
New Revision: 5647
Modified:
django/branches/0.91-bugfixes/django/core/meta/__init__.py
Log:
0.91-bugfixes: Fix problem parsing values from ManyToManyField with
raw_id_admin. Thanks, Tom Tobin
Modified: django/branches/0.91-bugfixes/django/core/meta/__init__.py
===================================================================
--- django/branches/0.91-bugfixes/django/core/meta/__init__.py 2007-07-11
07:12:50 UTC (rev 5646)
+++ django/branches/0.91-bugfixes/django/core/meta/__init__.py 2007-07-11
17:41:58 UTC (rev 5647)
@@ -1134,6 +1134,14 @@
# Handles setting many-to-many relationships.
# Example: Poll.set_sites()
def method_set_many_to_many(rel_field, self, id_list):
+ if len(id_list) == 1 and isinstance(id_list[0], basestring) and ',' in
id_list[0]:
+ new_id_list = []
+ for bit in id_list[0].split(','):
+ try:
+ new_id_list.append(int(bit.strip()))
+ except ValueError:
+ continue
+ id_list = new_id_list
current_ids = [getattr(obj, obj._meta.pk.attname) for obj in
method_get_many_to_many(rel_field, self)]
ids_to_add, ids_to_delete = dict([(i, 1) for i in id_list]), []
for current_id in current_ids:
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---