On Thu, 2006-08-17 at 05:14 -0700, [EMAIL PROTECTED] wrote: > OK, Jeremy, Ian, you've lost me now.. > > Is there something wrong with the code I posted above? It appears to be > working fine. Is there something superior about this: > > > > from django.core.models import LazyDate > > ... > > 'queryset': Show.objects.filter(show_date__gte=LazyDate()),
In your original code, the datetime.now() call is evaluated exactly once, when the code is imported. So if you leave that code running for a long time (more than a day), the date in your queryset will not change, even though time marches on. It will always do the filtering with respect to the date you imported that module. The version that Ian and Jeremy are talking about uses a special object that re-evaluates the current date each time it is used. So even if your code runs across a midnight boundary, it will still filter relevant to the current date. You probably aren't seeing any problem with your code at the moment because it isn't running for long enough. The only way you would see a problem in testing is if you are working late into the night and happen to start your dev server just before midnight and make a request just after midnight. Then you would scratch your head a bit, restart it to test again and not be able to reproduce the problem. And then you would roll out into production and the mysteries would begin (been there, done that, bought the T-shirt). :-) Best wishes, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---