caktus/django-timepiece — pull request #629 by antonlopatin (2013-01-14 18:52:28+00:00)
Title: Remove dependency on PostgreSQL's DATE_TRUNC to allow other db backends.

Hi there,

Just been playing around with the example_project using the sqlite3 backend (not having a PostgreSQL server installed). All I did was to remove the hard coded DATE_TRUNC sql strings and use django.db.connection.ops.date_trunc_sql. There is no much documentation on this in the django docs, but this interface seems to have been around since at least Django 1.0.

With these changes the sqlite3 backend works quite nicely for me. I've encountered no problems so far, but since I'm not an experienced user (yet) I could have missed some other dependency on PostgreSQL. As date_trunc_sql is provided by django itself, it also should allow to use of the MySQL backend (untested).

On the PostrgeSQL backend nothing should change (untested!), as date_trunc_sql is just a thin wrapper in that case:
https://github.com/django/django/blob/master/django/db/backends/postgresql_psycopg2/operations.py#L37

Maybe this helps!