Re: Django's str(queryset.query) returns invalid SQL if I compare datetimes

2019-08-23 Thread Abdulrasheed Ibrahim
What is your model, is 'date' a DateField or a CharField? On Thu, Aug 22, 2019, 12:47 PM wd QuerySet.query is not a plain string, it's an Query object, you can check > the source code > > def __str__(self): >> """ >> Return the query as a string of SQL with the parameter values >> su

Re: Django's str(queryset.query) returns invalid SQL if I compare datetimes

2019-08-22 Thread wd
QuerySet.query is not a plain string, it's an Query object, you can check the source code def __str__(self): > """ > Return the query as a string of SQL with the parameter values > substituted in (use sql_with_params() to see the unsubstituted string). > > Parameter values won't ne

Re: Django's str(queryset.query) returns invalid SQL if I compare datetimes

2019-08-22 Thread Cornelis Poppema
What makes sense to me is the query builder (ORM) in Django "escapes"/quotes the values at the very last moment: whenever the query is to be executed in a database. Different databases can have different escape characters. When you print queryset.query it simply isn't at a stage where the escap

Django's str(queryset.query) returns invalid SQL if I compare datetimes

2019-08-20 Thread Jo
I have a Django queryset that I prepare with queryset.filter(date__gte=datetime(2011,1,1)) If I then call `str(queryset.query)` I see this in the string: ... WHERE "App_table"."date" >= 2011-1-1 However, this is invalid SQL code as if I run this in Postgresql I get this error: ... W