Re: How to filter a query set based on a calculated date value?

2010-05-03 Thread Nuno Maltez
You can try the extra() method and write some SQL: http://docs.djangoproject.com/en/dev/ref/models/querysets/#extra-select-none-where-none-params-none-tables-none-order-by-none-select-params-none Something like (you'd need the correct functions for adding time and finding the current date for

Re: How to filter a query set based on a calculated date value?

2010-04-30 Thread Daniel Roseman
On Apr 30, 11:26 am, Derek wrote: > I would like to be able to filter a query set based on a calculated date > value.  Googling did not bring up anything obvious. > > As close as I can express it in "pseudo syntax", I'd like to do something > along these lines: > > import

Re: How to filter a query set based on a calculated date value?

2010-04-30 Thread Dj Gilcrease
On Fri, Apr 30, 2010 at 6:26 AM, Derek wrote: > MyModel.objects.filter( (my_date_field + relativedelta(months = > +my_month_field))__lt = today ) wouldnt that be the same as my_date_field__gt=(today - relativedelta(months=my_month_field)) my_date_field + my_month_field <

How to filter a query set based on a calculated date value?

2010-04-30 Thread Derek
I would like to be able to filter a query set based on a calculated date value. Googling did not bring up anything obvious. As close as I can express it in "pseudo syntax", I'd like to do something along these lines: import datetime from dateutil.relativedelta import * today = datetime.now()