aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/compat.py
diff options
context:
space:
mode:
authorTom Christie2013-06-26 21:18:13 +0100
committerTom Christie2013-06-26 21:18:13 +0100
commit69e5e3cc0db481e4fad7ac34bf28b73f4786e790 (patch)
tree9543d737204fa7f766f9d497117247fc92424b86 /rest_framework/compat.py
parent715bd47dfababd39be9b3295ada99f2107d7c00c (diff)
downloaddjango-rest-framework-69e5e3cc0db481e4fad7ac34bf28b73f4786e790.tar.bz2
Use timezone aware datetimes with oauth2 provider, when supported. Closes #947.
Diffstat (limited to 'rest_framework/compat.py')
-rw-r--r--rest_framework/compat.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/rest_framework/compat.py b/rest_framework/compat.py
index 69853730..b748dcc5 100644
--- a/rest_framework/compat.py
+++ b/rest_framework/compat.py
@@ -2,6 +2,7 @@
The `compat` module provides support for backwards compatibility with older
versions of django/python, and compatibility wrappers around optional packages.
"""
+
# flake8: noqa
from __future__ import unicode_literals
@@ -489,12 +490,21 @@ try:
from provider.oauth2 import forms as oauth2_provider_forms
from provider import scope as oauth2_provider_scope
from provider import constants as oauth2_constants
+ from provider import __version__ as provider_version
+ if provider_version in ('0.2.3', '0.2.4'):
+ # 0.2.3 and 0.2.4 are supported version that do not support
+ # timezone aware datetimes
+ from datetime.datetime import now as provider_now
+ else:
+ # Any other supported version does use timezone aware datetimes
+ from django.utils.timezone import now as provider_now
except ImportError:
oauth2_provider = None
oauth2_provider_models = None
oauth2_provider_forms = None
oauth2_provider_scope = None
oauth2_constants = None
+ provider_now = None
# Handle lazy strings
from django.utils.functional import Promise