Code

Ticket #1064: onetoonefix.diff

File onetoonefix.diff, 698 bytes (added by bruce@…, 8 years ago)

Fix!

Line 
1Index: django/core/meta/__init__.py
2===================================================================
3--- django/core/meta/__init__.py        (revision 1642)
4+++ django/core/meta/__init__.py        (working copy)
5@@ -1135,7 +1135,7 @@
6 # Handles setting many-to-many relationships.
7 # Example: Poll.set_sites()
8 def method_set_many_to_many(rel_field, self, id_list):
9-    current_ids = [obj.id for obj in method_get_many_to_many(rel_field, self)]
10+    current_ids = [getattr(obj, obj._meta.pk.attname) for obj in method_get_many_to_many(rel_field, self)]
11     ids_to_add, ids_to_delete = dict([(i, 1) for i in id_list]), []
12     for current_id in current_ids:
13         if current_id in id_list:
14