aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/compat.py
diff options
context:
space:
mode:
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