On Thu, Jul 5, 2012 at 1:28 PM, hinnack <[email protected]> wrote:
> hmm, Ok, Queryset Caching happens alle the time...
>
> So here are some more questions on this:
> - where is the data stored?
> - can I ask a model, if its result is cached or a fresh one?
> - can I disable or force a "refresh" of the cache?
> - how would i use a query in a property of a class, without running into the
> cache phenomena?
>
> regards
>
> Henrik
>

Could you show where and how you are executing the query? If the
queryset is a global, and does not go out of scope at the end of the
request, then reusing the queryset will not cause the queryset to be
re-evaluated.

Eg, in this example, categories is a global outside of the view, and
once evaluated, will not be re-evaluated just because you used it in a
view.

categories = Category.objects.all()

def index(request):
  return render_to_response('index.html': { 'categories': categories })

When querysets are executed is documented here:

https://docs.djangoproject.com/en/1.4/ref/models/querysets/#when-querysets-are-evaluated

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
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.

Reply via email to