﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
26767	Modifications to a prefetched many-to-many field should clear the cache	Matt d'Entremont	nobody	"We were running into issues with stale data, and discovered that the cause was prefetched data sticking around after field updates.

Example code:
{{{#!python
class Books(Model):
    ...
    author = models.ForeignKey('Author', related_name='books')

class Author(Model)
    ...


first_author = Author.objects.prefetch_related('books')[0]
first_author.books = []

print first_author.books.count()  # Gotcha!
}}}

After performing the `first_author.books = []`, the proper changes are made to the through model. However, when performing `first_author.books.count()`, the result may not be `0`; but will instead be the number of books associated with the author before the `first_author.books = []` statement.

What would be nice would be either:
- Update the prefetched cache for a field when a the field is changed
- Clear the prefetched cache for a field when the field is changed

"	Bug	closed	Database layer (models, ORM)	1.9	Normal	duplicate			Unreviewed	0	0	0	0	0	0
