I am for the clearing of the cache--that behavior seems weird.  If you 
didn't want the cache to clear you would probably be using a different orm 
object to do your query.

Just to be clear, after clearing the cache, any future requests against 
that data will be lazily evaluated right?

-Ben

On Tuesday, June 7, 2016 at 5:26:42 AM UTC-7, Yoong Kang Lim wrote:
>
> Hi all, I'd like to bring up ticket #26706: 
> https://code.djangoproject.com/ticket/26706
>
> Related managers have methods such as add(), change() and remove() that 
> change database objects. When a prefetch_related is done prior to calling 
> these methods, it does not clear the cache. When the related field is 
> accessed, it returns the cached result instead of the updated result. A 
> couple of tickets have been opened, as this does seem to be surprising 
> behaviour.
>
> I was working on a patch to address this, but Tim brought up some concerns 
> about backward compatibility regarding the change and directed me here to 
> get some community consensus. The change I'm proposing will clear the cache 
> (for the prefetched field) when any of the methods are called. If we 
> introduce this, it will be a backwards-incompatible change, so I'd just 
> like to get some opinions on what the best way forward would be. Obviously 
> in either case the behaviour should be documented. 
>
> Also a thought just occurred to me -- if we don't put this change in, 
> could we, as an alternative solution, extend the API to let the user decide 
> what to do with the cache? Maybe something like 
> clear_prefetched_field(related_field_name) on the manager so that at least 
> the user has a choice instead of running the query (although the trouble 
> they would need to go through would be similar, IMO).
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/ad5c2d3f-e00c-42f6-b519-4d294a6c0c78%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to