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 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 the code I've developed. > > If possible, I'd like to be able to cache these queries when these > views are called. A lot of the queries are simply re-produced but > perform different calculations or what-not based on the method called. > > These views do not create persistent data; they simply hit the > database and return calculated results from what's in there. > > The caching mechanism should simply persist through the duration of > the request. For example, subsequent requests should not use cached > results from a previous request. > > Let me know if anybody has suggestions or experience with implementing > something along these lines. I have some 'creative' ideas on how to do > it but I'd like to get some input first. > > Thanks! > - Kurtis > -- > You received this message because you are subscribed to the Google > Groups "Django users" 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 http://groups.google.com/group/django-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > -- You received this message because you are subscribed to the Google Groups "Django users" 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 http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.

