Sorry, I did not specify.
I have been using 'Postgresql' with 'psycopg2 v.2.6.2'.
They gave me those results.

Also here is a sql query given from log:
SELECT "test_app_entity"."id", "test_app_entity"."due_date",
"test_app_entity"."interval", (("test_app_entity"."due_date" -
'2016-08-03T21:31:58.325549+00:00'::timestamptz) /
"test_app_entity"."interval") AS "ratio" FROM "test_app_entity";
args=(datetime.datetime(2016, 8, 3, 21, 31, 58, 325549, tzinfo=<UTC>),)

That is all that I can say at the moment.

On Thu, Aug 4, 2016 at 12:20 AM, Yoann Duriaud <yoann.duri...@gmail.com>
wrote:

> Thanks, unfortunately not so great on my side:
>
> I added in the query (forgetting the division for now):
>
> .annotate(ratio=ExpressionWrapper(F('due_date')-timezone.now(),
> DateTimeField()))
>
>
> which leads to the following statement in the query:
>
> ("contentstatus"."due_date" - 2016-08-03 21:05:10.743799+00:00) AS "ratio"
>
>
> This is not a valid SQL statement (at least for SQLite) and leads to the
> following error message when the query is evaluated:
>
> Exception Type:
>
> TypeError
> Exception Value:
>
>
> expected string or bytes-like object
>
>
> Any idea what I 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 "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/038837c5-6b5b-4ae9-895a-b6b54282d978%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/038837c5-6b5b-4ae9-895a-b6b54282d978%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/CAK52boX3b%2Bb6okqsKVXX%3DxQ7HUss9qL_BRbL8rpWFGE%3Ds2xL9g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to