Re: Filter by retirement age?

2012-05-09 Thread Lachlan Musicman
Thanks Nikolas - that works. cheers L. On Wednesday, May 9, 2012, Nikolas Stevenson-Molnar wrote: > On your second attempt, the problem is that you are trying to call the > datetime module, not the datetime class. Change it to > datetime.datetime(...) and you should be fine there. > > _Nik > >

Re: Filter by retirement age?

2012-05-09 Thread Lachlan Musicman
Thanks Tom, but I get an error because timedelta doesn't take years - I've changed it to weeks=3120 and it works. Because of that error I've also found another thread discussing the issue: http://stackoverflow.com/questions/765797/python-timedelta-in-years I liked the most popular answer's stand

Re: Filter by retirement age?

2012-05-09 Thread Tom Evans
On Wed, May 9, 2012 at 12:12 AM, Lachlan Musicman wrote: > Hola, > > I have a model Person with a dob = models.DateField() > > I would like to filter by age - in particular only include people less than > 60 years old. > > I am having no luck getting the syntax right and was looking for pointers?

Re: Filter by retirement age?

2012-05-08 Thread Nikolas Stevenson-Molnar
On your second attempt, the problem is that you are trying to call the datetime module, not the datetime class. Change it to datetime.datetime(...) and you should be fine there. _Nik On 5/8/2012 4:12 PM, Lachlan Musicman wrote: > Hola, > > I have a model Person with a dob = models.DateField() > >

Filter by retirement age?

2012-05-08 Thread Lachlan Musicman
Hola, I have a model Person with a dob = models.DateField() I would like to filter by age - in particular only include people less than 60 years old. I am having no luck getting the syntax right and was looking for pointers? queryset=Person.objects.filter(dob__year__gte = datetime.dat