Re: Suggestions on caching queries for a single request on a subset of Views?

2013-06-10 Thread Nikolas Stevenson-Molnar
I created a simple decorator for this purpose: http://djangosnippets.org/snippets/2874/ Wrap your expensive model methods with @auto_memoize and the results will be cached in memory for the duration of the request. _Nik On 6/10/2013 9:58 AM, Kurtis wrote: > I have two views which perform a ton

Re: Suggestions on caching queries for a single request on a subset of Views?

2013-06-10 Thread Marcin Szamotulski
Hi, I am not en expert but since I had a similar problem I found a solution. I just attached data I wanted to persist to the request. You can put the common code in a middleware to be computed early and then use it in your views. You can also add it to the session data (i.e. request.session)

Suggestions on caching queries for a single request on a subset of Views?

2013-06-10 Thread Kurtis
I have two views which perform a ton of DB queries. The views themselves don't perform the queries; they simply call quite a few Model methods to build the context data. I understand that I could simply build one method to re-use the data but I'd like to sustain the "Object Oriented" quality of