Hi Yoann,

I am not sure exactly but believes you are on the right way.
Try improve your expression with ExpressionWrapper, as said here
<https://docs.djangoproject.com/en/1.9/ref/models/expressions/#using-f-with-annotations>
.
Probably the problem is that you use values of different types in your
expression.

Regards

On Sat, Jul 30, 2016 at 11:35 PM, Yoann Duriaud <yoann.duri...@gmail.com>
wrote:

> Hello,
> I would like to annotate a query with the following expression: ([Due
> Date] - [Now])/[Interval]. [Due Date] and [Interval] are fields from the
> database, while [Now] should be "equal" to timezone.now().
>
> So this would look like:
> .annotate(ratio=(F('due_date')-timezone.now())/F('Interval'))
>
> but this does not work. Does someone know how the expression should be
> written (if it is indeed feasible with Django ORM)?
>
> Thanks for your help!
>
> Yoann
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/03dedd39-142f-468a-b6fd-b7ec551862e8%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/03dedd39-142f-468a-b6fd-b7ec551862e8%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK52boX7irnk5X8GjUACuHCTDjzHpjHvpmP0O_fbUfhJZDAP6w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to