I need to group and count items by date. I got it on sqlite with the followint:
Books.objects.filter(state="new").extra({"published_at": "date(published_at)"}).values("published_at").annotate(counter=Count("pk"))
But the use of extra() with sql statement cannot be portable on other dbms. For example the above doesn't work on mysql. How i can have a working query for sqlite, postgresql and mysql?