#33984: Related managers cache gets stale after saving a fetched model with new PK -------------------------------------+------------------------------------- Reporter: joeli | Owner: nobody Type: Bug | Status: new Component: Database layer | Version: 4.1 (models, ORM) | Severity: Release blocker | Resolution: Keywords: | Triage Stage: Accepted Has patch: 1 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by Bhuvnesh):
* has_patch: 0 => 1 Comment: [https://github.com/django/django/pull/16047 PR] Added a condition to refresh {{{related_managers_cache}}} when {{{self.pk is None}}} and {{{self._state.adding is True}}}. If {{{self.pk = None}}} will be missing then the instance would not be cloned and if {{{self._state.adding = True}}} is missing then related_manangers_cache would not be refreshed generating inconsistent results, hence both the conditions are necessary. It is also mentioned in [https://docs.djangoproject.com/en/4.1/topics/db/queries/#copying-model- instances docs.] -- Ticket URL: <https://code.djangoproject.com/ticket/33984#comment:11> 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 view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/0107018329461973-8677b476-b5d3-4035-8d06-addc9dbde53f-000000%40eu-central-1.amazonses.com.