Re: Query annotation with date difference

2016-08-03 Thread Yoann Duriaud
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

Re: Query annotation with date difference

2016-08-01 Thread Yoann Duriaud
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 > >

Query annotation with date difference

2016-07-30 Thread Yoann Duriaud
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'))