summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Yusko <mykhaylo.yusko@gmail.com>2019-12-21 22:18:14 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-01-09 07:54:18 +0100
commit0707ff6d366de6fbe08c8f70dd9d483344077711 (patch)
treed298e3753160bfc3c1c98bc0590cd5f2186dc9c0
parent6686238cdc5c826ca5aab39d771798ff98e90ae8 (diff)
Renamed set_language()'s next variable to avoid clash with builtin.
-rw-r--r--django/views/i18n.py27
1 files changed, 16 insertions, 11 deletions
diff --git a/django/views/i18n.py b/django/views/i18n.py
index cbe61bcf88..17eb4f9f61 100644
--- a/django/views/i18n.py
+++ b/django/views/i18n.py
@@ -31,26 +31,31 @@ def set_language(request):
redirect to the page in the request (the 'next' parameter) without changing
any state.
"""
- next = request.POST.get('next', request.GET.get('next'))
+ next_url = request.POST.get('next', request.GET.get('next'))
if (
- (next or not request.is_ajax()) and
+ (next_url or not request.is_ajax()) and
not url_has_allowed_host_and_scheme(
- url=next, allowed_hosts={request.get_host()}, require_https=request.is_secure(),
+ url=next_url,
+ allowed_hosts={request.get_host()},
+ require_https=request.is_secure(),
)
):
- next = request.META.get('HTTP_REFERER')
- next = next and unquote(next) # HTTP_REFERER may be encoded.
+ next_url = request.META.get('HTTP_REFERER')
+ # HTTP_REFERER may be encoded.
+ next_url = next_url and unquote(next_url)
if not url_has_allowed_host_and_scheme(
- url=next, allowed_hosts={request.get_host()}, require_https=request.is_secure(),
+ url=next_url,
+ allowed_hosts={request.get_host()},
+ require_https=request.is_secure(),
):
- next = '/'
- response = HttpResponseRedirect(next) if next else HttpResponse(status=204)
+ next_url = '/'
+ response = HttpResponseRedirect(next_url) if next_url else HttpResponse(status=204)
if request.method == 'POST':
lang_code = request.POST.get(LANGUAGE_QUERY_PARAMETER)
if lang_code and check_for_language(lang_code):
- if next:
- next_trans = translate_url(next, lang_code)
- if next_trans != next:
+ if next_url:
+ next_trans = translate_url(next_url, lang_code)
+ if next_trans != next_url:
response = HttpResponseRedirect(next_trans)
if hasattr(request, 'session'):
# Storing the language in the session is deprecated.