Log a WARNING when the infinite redirect happens
@@ -117,8 +117,14 @@ def server_error_404(request, exception=None, template_name='404.html'): # pyli
"""
response = get_redirect_response(request, path=request.get_full_path())
- if response and response.url != request.build_absolute_uri():
+ if response:
+ if response.url == request.build_absolute_uri():
# check that we do have a response and avoid infinite redirect
+ log.warning(
+ 'Infinite Redirect: FROM URL is the same than TO URL. url=%s',
+ response.url,
+ )
+ else:
return response
r = render(request, template_name)
r.status_code = 404
