Hi Simon,

On Feb 2, 7:36 am, Simon Westphahl <westph...@googlemail.com> wrote:
> ###
> class OfferManager(models.Manager):
>     def get_query_set(self):
>         return super(OfferManager, self).get_query_set().exclude
> (start_date__gt=datetime.now).exclude(end_date__lt=datetime.now)
> ###
>
> I'm using a queryset filtered with a callable (datetime.now) which
> appears to be set only once/on load time?!

I think you've got the right idea of what's going wrong, but you're
looking for the problem in the wrong place.  This method isn't module-
level code; it will be executed anew each time you query on this
manager.  More likely is that you're storing a reference to the
returned queryset in module-level code; probably in a dictionary of
kwargs you're passing to the object_detail generic view (most likely
in your urls.py).  It's that queryset that is never getting updated;
the call to your manager method is happening only once, when the
urls.py module is first loaded.

The solution is to wrap the object_detail view with a very lightweight
view of your own that calls the manager method and passes the
resulting queryset in to object_detail.  Then the queryset will be re-
created for each request.

Carl
--~--~---------~--~----~------------~-------~--~----~
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