aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/compat.py
diff options
context:
space:
mode:
authorTom Christie2015-01-05 11:02:28 +0000
committerTom Christie2015-01-05 11:02:28 +0000
commit6168f60ba80a84768172437c09957c1fab05f014 (patch)
tree4922399b5996d6cd0fdeb4aad2fbb99698f3a1c8 /rest_framework/compat.py
parent889a0bdeca942995ab32bf19c3d9fdbfaeec58ec (diff)
parent8cf37449715c32c4a692667814466c7f32e8734f (diff)
downloaddjango-rest-framework-6168f60ba80a84768172437c09957c1fab05f014.tar.bz2
Merge branch 'master' into version-3.1
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 3c8fb0da..7241da27 100644
--- a/rest_framework/compat.py
+++ b/rest_framework/compat.py
@@ -55,6 +55,16 @@ except ImportError:
from django.http import HttpResponse as HttpResponseBase
+# request only provides `resolver_match` from 1.5 onwards.
+def get_resolver_match(request):
+ try:
+ return request.resolver_match
+ except AttributeError:
+ # Django < 1.5
+ from django.core.urlresolvers import resolve
+ return resolve(request.path_info)
+
+
# django-filter is optional
try:
import django_filters