You can't add a datetime to another datetime - you want to add a
datetime.timedelta instance instead. Out of curiosity I just tested it
on one of my models and it does work, e.g.,

MyModel.objects.filter(update_date__gt=F('entry_date')+timedelta(days=5))

On Thu, Oct 14, 2010 at 5:57 PM, Marc Aymerich <glicer...@gmail.com> wrote:
>
>
> On Thu, Oct 14, 2010 at 10:08 PM, Alec Shaner <asha...@chumpland.org> wrote:
>>
>> See this:
>>
>> http://ifacethoughts.net/2009/07/14/calculated-fields-in-django/
>>
>> So perhaps the 'extra' query filter is what you need.
>>
>
> Yep, I got a success using extra filter :) Thanks Alec for sharing this!
> by the way, just right now I found the way to reference field on filter and
> operates with it. It can be achieved using instances of F()
>  http://docs.djangoproject.com/en/dev/topics/db/queries/#filters-can-reference-fields-on-the-model
> it could be more 'elegant' than using an extra filter, all I need is
> something like that:
> order.objects.filter(Q(cancel_date__isnull=False,
> cancel_date__lt=F('register_date') + Threshold)
> | Q(cancel_date__isnull=True, register_date__gt=Threshold) )
> but i couldn't get working this part: "F('register_date')+Threshold"
> ,(threshold is a datetime.datetime object, and also 'register_date' field.
> Anyone knows the correct way to use instances of F() with date field?
>
> --
> Marc
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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