On Wed, May 13, 2009 at 5:00 PM, eric.frederich <eric.freder...@gmail.com>wrote:
> > I have a model called Offering which has a start date and a duration > in days. > I want to do a query and get instances where the end date (not > modeled) is in the past. > I know that I can add a non-editable field end-date that is computed > in the save method, but this seems denormalized. > I'm curious to see if this is possible using only a start date, > duration, and queries. You might be able to do so with the field reference function F(): http://docs.djangoproject.com/en/dev/topics/db/queries/#filters-can-reference-fields-on-the-model Maybe this works (untested): Offering.objects.filter(date__lt=datetime.today() + F('duration')) TiNo > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---