Changes between Initial Version and Version 1 of Ticket #33984
- Timestamp:
- Sep 6, 2022, 6:33:33 AM (2 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #33984 – Description
initial v1 1 I'm upgrading our codebase from Django 3.2 to 4.1, and came upon a regression when running our test suite. I bisected it down to commit [4f8c7fd9d9 Fixed #32980 -- Made models cache related managers](https://github.com/django/django/commit/4f8c7fd9d91b35e2c2922de4bb50c8c8066cbbc6).1 I'm upgrading our codebase from Django 3.2 to 4.1, and came upon a regression when running our test suite. I bisected it down to commit 4f8c7fd9d9 Fixed #32980 -- Made models cache related managers: [https://github.com/django/django/commit/4f8c7fd9d91b35e2c2922de4bb50c8c8066cbbc6] 2 2 3 3 The main problem is that when you have fetched a model containing a m2m field from the database, and access its m2m field the manager gets cached. If you then set the model's `.pk` to `None` and do a `.save()` to save it as a copy of the old one, the related manager cache is not cleared. Here's some code with inline comments to demonstrate: