#8467: For ManyToMany manager, we should convert objects being added or removed 
to
the pk type if they are not.
-----------------------------------------------------------+----------------
 Reporter:  Wonlay                                         |       Owner:  
nobody    
   Status:  new                                            |   Milestone:  1.0  
     
Component:  Core framework                                 |     Version:  SVN  
     
 Keywords:  Duplicate entry, add, remove, ManyToManyField  |       Stage:  
Unreviewed
Has_patch:  1                                              |  
-----------------------------------------------------------+----------------
 For example:
 {{{
 class A(models.Model):
         name = models.CharField(blank=True)

 class B(models.Model):
         a = models.ManyToManyField(A)

 a = A(name='aaa')
 a.save()
 b = B()
 b.save()

 # This line works fine:
 b.a.add('1')

 # But this one will raise 'Duplicate entry' error:
 b.a.add('1')
 }}}

 This is caused by {{{ '1' }}} is not an integer, the duplication checking
 code in {{{ add() }}} fails when checking the string type {{{'1'}}}.

 The same problem is applied to the {{{ remove() }}} method.

 If we convert the objects to its pk type of the model, code will run
 correctly.

 And my patch is attached.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/8467>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to