diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py index 8000300055..1dca15b4aa 100644 --- a/django/core/urlresolvers.py +++ b/django/core/urlresolvers.py @@ -383,10 +383,6 @@ class RegexURLResolver(LocaleRegexProvider): text_args = [force_text(v) for v in args] text_kwargs = dict((k, force_text(v)) for (k, v) in kwargs.items()) - if isinstance(lookup_view, six.string_types): - # Handle relative URLs - if any(lookup_view.startswith(path) for path in ('./', '../')): - return lookup_view try: lookup_view = get_callable(lookup_view, True) except (ImportError, AttributeError) as e: diff --git a/django/shortcuts.py b/django/shortcuts.py index 17a860d87e..62560472c1 100644 --- a/django/shortcuts.py +++ b/django/shortcuts.py @@ -10,6 +10,7 @@ from django.db.models.base import ModelBase from django.db.models.manager import Manager from django.db.models.query import QuerySet from django.core import urlresolvers +from django.utils import six def render_to_response(*args, **kwargs): @@ -147,6 +148,11 @@ def resolve_url(to, *args, **kwargs): if hasattr(to, 'get_absolute_url'): return to.get_absolute_url() + if isinstance(to, six.string_types): + # Handle relative URLs + if any(to.startswith(path) for path in ('./', '../')): + return to + # Next try a reverse URL resolution. try: return urlresolvers.reverse(to, args=args, kwargs=kwargs)