#32045: Removing item from GenericRelation deletes all items.
-------------------------------------+-------------------------------------
     Reporter:  chgad                |                    Owner:  Asjad
                                     |  Ahmed Khan
         Type:  Bug                  |                   Status:  closed
    Component:                       |                  Version:  3.0
  contrib.contenttypes               |
     Severity:  Normal               |               Resolution:  needsinfo
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by chgad):

 Replying to [comment:6 felixxm]:
 > Thanks for this ticket, however everything works for me with provided
 models:
 > {{{
 > class MyTests(TestCase):
 >     def test_1(self):
 >         p1 = MyProfile.objects.create(name='profile1')
 >         p2 = MyProfile.objects.create(name='profile2')
 >         photo1 = Photograph.objects.create(profile=p1)
 >         photo2 = Photograph.objects.create(profile=p1)
 >         photo3 = Photograph.objects.create(profile=p2)
 >         self.assertEqual(Photograph.objects.count(), 3)
 >         self.assertCountEqual(p1.photos.all(), [photo1, photo2])
 >         self.assertCountEqual(p2.photos.all(), [photo3])
 >         p1.photos.remove(photo1)
 >         self.assertCountEqual(p1.photos.all(), [photo2])
 >         self.assertCountEqual(p2.photos.all(), [photo3])
 >         self.assertEqual(Photograph.objects.count(), 2)
 > }}}
 >
 > Can you provide a small sample project that reproduces this issue?

 That is what I'm describing. But `remove` should not delete the `photo1`
 entry. So with your example Test I expect the last assertion fail!

 As the docs. describe `remove` is expected to remove an entry from the
 Relation `p1.photos.all()` but keep it in the Database, unlinked to a
 profile.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32045#comment:7>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.04e24d72c9365a248ff45f88e2b543e4%40djangoproject.com.

Reply via email to