From 77d061d234e03004f34058028707ecddfc730fae Mon Sep 17 00:00:00 2001 From: Brandon Cazander Date: Wed, 28 Jan 2015 17:08:34 -0800 Subject: Provide rest_framework.resolve. Fixes #2489 --- rest_framework/reverse.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'rest_framework/reverse.py') diff --git a/rest_framework/reverse.py b/rest_framework/reverse.py index 8fcca55b..0d1d94a7 100644 --- a/rest_framework/reverse.py +++ b/rest_framework/reverse.py @@ -1,12 +1,25 @@ """ -Provide reverse functions that return fully qualified URLs +Provide urlresolver functions that return fully qualified URLs or view names """ from __future__ import unicode_literals from django.core.urlresolvers import reverse as django_reverse +from django.core.urlresolvers import resolve as django_resolve from django.utils import six from django.utils.functional import lazy +def resolve(path, urlconf=None, request=None): + """ + If versioning is being used then we pass any `resolve` calls through + to the versioning scheme instance, so that the resulting view name + can be modified if needed. + """ + scheme = getattr(request, 'versioning_scheme', None) + if scheme is not None: + return scheme.resolve(path, urlconf, request) + return django_resolve(path, urlconf) + + def reverse(viewname, args=None, kwargs=None, request=None, format=None, **extra): """ If versioning is being used then we pass any `reverse` calls through -- cgit v1.2.3 From e1c45133126e0c47b8470b4cf7a43c6a7f4fca43 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 5 Feb 2015 00:58:09 +0000 Subject: Fix NamespaceVersioning with hyperlinked serializer fields --- rest_framework/reverse.py | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'rest_framework/reverse.py') diff --git a/rest_framework/reverse.py b/rest_framework/reverse.py index 0d1d94a7..a251d99d 100644 --- a/rest_framework/reverse.py +++ b/rest_framework/reverse.py @@ -3,23 +3,10 @@ Provide urlresolver functions that return fully qualified URLs or view names """ from __future__ import unicode_literals from django.core.urlresolvers import reverse as django_reverse -from django.core.urlresolvers import resolve as django_resolve from django.utils import six from django.utils.functional import lazy -def resolve(path, urlconf=None, request=None): - """ - If versioning is being used then we pass any `resolve` calls through - to the versioning scheme instance, so that the resulting view name - can be modified if needed. - """ - scheme = getattr(request, 'versioning_scheme', None) - if scheme is not None: - return scheme.resolve(path, urlconf, request) - return django_resolve(path, urlconf) - - def reverse(viewname, args=None, kwargs=None, request=None, format=None, **extra): """ If versioning is being used then we pass any `reverse` calls through -- cgit v1.2.3