#18823: Clear with a M2M field with a through model -------------------------------------+------------------------------------- Reporter: anonymous | Owner: nobody Type: Bug | Status: new Component: Database layer | Version: 1.4 (models, ORM) | Resolution: Severity: Release blocker | Triage Stage: Accepted Keywords: | Needs documentation: 0 Has patch: 1 | Patch needs improvement: 0 Needs tests: 0 | UI/UX: 0 Easy pickings: 0 | -------------------------------------+------------------------------------- Changes (by russellm):
* severity: Normal => Release blocker * stage: Unreviewed => Accepted Comment: Via django-developers -- this bug has the potential for inadvertant data loss: {{{ class Through(models.Model): two = models.ForeignKey('Model2', to_field='spot') one = models.ForeignKey('Model1') class Model1(models.Model): name = models.CharField(max_length=100) class Model2(models.Model): spot = models.IntegerField(unique=True) ones = models.ManyToManyField(Model1, through=Through) # Create objects and relations m = Model1(name='test') m2 = Model2(spot=2, pk=1) m3 = Model2(spot=1, pk=2) m.save() m2.save() m3.save() Through(two=m2, one=m).save() Through(two=m3, one=m).save() # Both have ones m2.ones.all() m3.ones.all() m2.ones.clear() # Still has ones, didn't get deleted when it should have m2.ones.all() # This got deleted instead m3.ones.all() }}} -- Ticket URL: <https://code.djangoproject.com/ticket/18823#comment:3> 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 post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.