diff options
| author | Tom Christie | 2014-12-28 12:02:52 +0000 |
|---|---|---|
| committer | Tom Christie | 2014-12-28 12:02:52 +0000 |
| commit | efa5942ce1c5d2286fd91994b52fb73a5690426c (patch) | |
| tree | 1256cb860591572c515cbd4b7363a12dd29fb600 /rest_framework/compat.py | |
| parent | 67fc002f91e5dc617dab45895ded32d6be6c2a40 (diff) | |
| download | django-rest-framework-efa5942ce1c5d2286fd91994b52fb73a5690426c.tar.bz2 | |
Support namespaced router URLs with DefaultRouter.
Diffstat (limited to 'rest_framework/compat.py')
| -rw-r--r-- | rest_framework/compat.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/rest_framework/compat.py b/rest_framework/compat.py index 69fdd793..ba26a3cd 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -50,6 +50,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 |
