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\')\")
Generally, you escape a % with another %, e.g.:
%
Log.objects.raw("SELECT pub_date FROM foo_log GROUP BY DATE_FORMAT(pub_date,'%%Y%%m%%d')")
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