escaping for objects.raw()

前端 未结 2 1951
-上瘾入骨i
-上瘾入骨i 2021-01-15 01:55

I need a custom SQL query and try to use this:

Log.objects.raw(\"SELECT pub_date FROM foo_log GROUP BY DATE_FORMAT(pub_date,\'%Y%m%d\')\")

2条回答
  •  灰色年华
    2021-01-15 02:16

    Rather then raw SQL you could use dates for the above query.

    Log.objects.dates('pub_date', 'day')
    

    would return all the distinct dates by y/m/d

提交回复
热议问题