summaryrefslogtreecommitdiff
path: root/django/shortcuts.py
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2015-01-09 22:18:34 +0100
committerClaude Paroz <claude@2xlibre.net>2015-01-10 10:05:02 +0100
commitd7bc37d611b43d58be4b430faf0b9813bcde29c6 (patch)
tree3cf286e0f09f2fc89dee888688d0c098669a4bb6 /django/shortcuts.py
parentf5c3a8bff57add71b801c9c44442ea0f8fa35858 (diff)
Fixed #24097 -- Prevented AttributeError in redirect_to_login
Thanks Peter Schmidt for the report and the initial patch. Thanks to ​Oktay Sancak for writing the original failing test and Alvin Savoy for supporting contributing back to the community.
Diffstat (limited to 'django/shortcuts.py')
-rw-r--r--django/shortcuts.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/django/shortcuts.py b/django/shortcuts.py
index b43c23a891..3bb2412526 100644
--- a/django/shortcuts.py
+++ b/django/shortcuts.py
@@ -18,6 +18,8 @@ from django.db.models.query import QuerySet
from django.core import urlresolvers
from django.utils import six
from django.utils.deprecation import RemovedInDjango20Warning
+from django.utils.encoding import force_text
+from django.utils.functional import Promise
def render_to_response(template_name, context=None,
@@ -182,6 +184,11 @@ def resolve_url(to, *args, **kwargs):
if hasattr(to, 'get_absolute_url'):
return to.get_absolute_url()
+ if isinstance(to, Promise):
+ # Expand the lazy instance, as it can cause issues when it is passed
+ # further to some Python functions like urlparse.
+ to = force_text(to)
+
if isinstance(to, six.string_types):
# Handle relative URLs
if any(to.startswith(path) for path in ('./', '../')):