Ticket #8467: smart_many2many_add_remove.patch
File smart_many2many_add_remove.patch, 1.2 KB (added by , 16 years ago) |
---|
-
django/db/models/fields/related.py
423 423 if isinstance(obj, self.model): 424 424 new_ids.add(obj._get_pk_val()) 425 425 else: 426 new_ids.add( obj)426 new_ids.add(self.model._meta.pk.to_python(obj)) 427 427 # Add the newly created or already existing objects to the join table. 428 428 # First find out which items are already added, to avoid adding them twice 429 429 cursor = connection.cursor() … … 453 453 if isinstance(obj, self.model): 454 454 old_ids.add(obj._get_pk_val()) 455 455 else: 456 old_ids.add( obj)456 old_ids.add(self.model._meta.pk.to_python(obj)) 457 457 # Remove the specified objects from the join table 458 458 cursor = connection.cursor() 459 459 cursor.execute("DELETE FROM %s WHERE %s = %%s AND %s IN (%s)" % \