#25550: Deprecate direct assignment to the reverse side of a related set -------------------------------------+------------------------------------- Reporter: timgraham | Owner: nobody Type: | Status: new Cleanup/optimization | Component: Database | Version: master layer (models, ORM) | Severity: Normal | Keywords: Triage Stage: | Has patch: 0 Unreviewed | Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 0 | -------------------------------------+------------------------------------- As [https://groups.google.com/d/topic/django- developers/RVivKK3vUnE/discussion proposed by Ansii] on django-developers:
{{{ >>> obj.reverse_fk_set = RelatedObj.objects.all() }}} What happens is that the `RelatedObj.objects.all()` queryset is iterated and each object of the queryset is saved with the fk changed to point to the `obj`. An implicit save. Now, I don't like the implicit saves at all. A variable assignment should not cause a database save. So, I would like to deprecate the current behavior. Assignment to `reverse_fk_set` (and I guess this goes for m2m, too) is no longer allowed. Instead you will need to explicitly do: {{{ >>> obj.reverse_fk_set.set(RelatedObj.objects.all()) }}} Now you are calling a method, and saving in this situation is OK and analogous to other related manager methods. Lets raise a deprecation warning on direct assignment to the `reverse_fk_set` and remove it. The message would be something like "Direct assignment to the reverse side of a related set is deprecated. Use .set() instead." -- Ticket URL: <https://code.djangoproject.com/ticket/25550> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/052.a9321b69f69528f0c456620a5924d346%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.