On Wed, May 18, 2011 at 11:45:46PM -0700, James Hargreaves wrote:
...
> Firstly, when I query for LIVE objects in my view via
> Article.live.all() if I refresh the page repeatedly I can see (in
> MYSQL logs) the same database query being made with exactly the same
> date in the where clause - ie - the datetime.datetime.now() is being
> evaluated at compile time rather than runtime. I need the date to be
> evaluated at runtime.

I can't reproduce such behavior.  `.get_query_set()` is evaluted when
queryset is returned from manager, so, maybe, you cache queryset
somewhere in your view?

> Secondly, when I use the articles_set method on the Category object
> this appears to work correctly - the datetime used in the query
> changes each time the query is run - again I can see this in the logs.
> However, I am not quite sure why this works, since I don't have
> anything in my code to say that the articles_set query should return
> LIVE entries only!?

The first manager defined on model is interepted as "default manager".
You probably want to put line with `live` manager after `objects`
manager in `Article` declaration.

> Finally, why is none of this being cached?

Not quite so, QuerySet has a cache [1].

.. [1] 
http://docs.djangoproject.com/en/1.3/topics/db/queries/#caching-and-querysets

-- 
Kirill Spitsin

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to