On Sep 15, 9:11 am, pihentagy <[EMAIL PROTECTED]> wrote: > Also for consistency and for performance reasons, is it possible to > somehow return the same QuerySet for both items, _which are in the > same request_? > > thanks > Gergo
I would suggest looking at the template fragment caching first and foremost to see if it will meet your needs: http://docs.djangoproject.com/en/dev/topics/cache/#template-fragment-caching With a very low timeout (a few seconds), you can probably eliminate duplicate queries without really impacting the dynamic feel of the sidebar for the user. If you really need per-request caching, I would suggest creating a custom middleware app that sets/resets its internal state with every call to process_request(). Since each request is handled by Django in a single process in a synchronous fashion, you can use the custom middleware as a static singleton in your code for the lifetime of the request (and actually, with persistent processes, it may live a lot longer than one request, but at minimum it is guaranteed to be available to you during the request lifetime). You could also use the low-level caching API for this, but you'd still probably want a custom middleware to reset the values of interest on each process_request() call, plus you'd need to be careful about choosing cache keys to make sure you are able to identify just the values of interest for the current process/request without stepping on other requests' values. - Keith --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---