1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

Fixed #21177 -- Made resolve_url support relative URLs.

This fixes redirecting to relative URLs with django.shortcuts.redirect.
This commit is contained in:
Antoine Catton
2014-02-13 20:48:44 -07:00
committed by Tim Graham
parent f3805f5c52
commit e3d0790bd0
4 changed files with 24 additions and 2 deletions

View File

@@ -383,6 +383,10 @@ 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: