From 1590ce17622aa01e93ec1ee37147ba4df9e46cba Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Tue, 8 Jul 2014 10:24:29 -0400 Subject: [PATCH] Work around a bug in django 1.4 and 1.5 for qsstats that would not allow it to work with USE_TZ = True --- awx/api/views.py | 7 ------- awx/lib/site-packages/qsstats/__init__.py | 6 ++++++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/awx/api/views.py b/awx/api/views.py index 7fdea4b508..8d11e067de 100644 --- a/awx/api/views.py +++ b/awx/api/views.py @@ -257,10 +257,6 @@ class DashboardGraphView(APIView): period = request.QUERY_PARAMS.get('period', 'month') job_type = request.QUERY_PARAMS.get('job_type', 'all') - # Working around a django 1.5 bug: - # https://code.djangoproject.com/ticket/17260 - settings.USE_TZ = False - qs = User.objects.all() user_unified_jobs = get_user_queryset(request.user, UnifiedJob) user_hosts = get_user_queryset(request.user, Host) @@ -322,9 +318,6 @@ class DashboardGraphView(APIView): this_inventory['sources'].append(this_source) dashboard_data['inventory'].append(this_inventory) - # Setting it back - settings.USE_TZ = True - return Response(dashboard_data) class ScheduleList(ListAPIView): diff --git a/awx/lib/site-packages/qsstats/__init__.py b/awx/lib/site-packages/qsstats/__init__.py index 68b04d0b89..519d7bbf10 100644 --- a/awx/lib/site-packages/qsstats/__init__.py +++ b/awx/lib/site-packages/qsstats/__init__.py @@ -122,6 +122,12 @@ class QuerySetStats(object): stat_list = [] dt = start + try: + from django.utils.timezone import utc + dt = dt.replace(tzinfo=utc) + end = end.replace(tzinfo=utc) + except ImportError: + pass while dt < end: idx = 0 value = 0