Can you please provide an example? I can't reproduce it: time_series tests work with django 1.4 TZ enabled for both postgres and sqlite (these configurations are in tox.ini).
It may be the case the result is not what is expected because django returns date aggregations in UTC ignoring time zones (and currently django-qsstats-magic follows this), see https://code.djangoproject.com/ticket/17260
I've got this problem too. I'm working with Django==1.4 USE_TZ=True settings and using PostgreSQL 9.x.
Here is simple workaround only for "_fast_time_series" method:
--- qsstats/__init__.py+++ qsstats/__init__.py@@ -122,6 +122,12 @@ class QuerySetStats(object):
stat_list = 
dt = start
+ try:+ from django.utils.timezones import utc+ dt = dt.replace(tzinfo=utc)+ end = end.replace(tzinfo=utc)+ except ImportError:+ pass
while dt < end:
idx = 0
value = 0
Sorry for just diff snippet. Unfortunely I haven't I enough time to make the full patch and cover code with test cases. I hope, that helps you to close this issue :-)
I can confirm this is happening on Django 1.5 with USE_TZ = True and sqlite, it looks like the ticket linked above has been resolved in the last 3 weeks, It didn't make the 1.5 cut, probably be 1.6 now before this is resolved.
I've had a look over the tests vs. what code I use at the moment and I suspected it was my use of utcnow() instead of now() like the tests. I've had a play around but can't seem to get it in a working state.
Thankfully my app doesn't require USE_TZ at the moment, so I can avoid this.
Here is a snippet of when i'm constructing the QSS, the model is a simple key/datetime/value model which is prefiltered by key.