get this behavior?
Yoann
Le samedi 30 juillet 2016 22:41:21 UTC+2, Yoann Duriaud a écrit :
>
> 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
t 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
>
>
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'))
3 matches
Mail list logo