def process_response(self, request, response): if (response.status_code == 404 and request.path_info.endswith('/') and not common._is_valid_path(request.path_info) and common._is_valid_path(request.path_info[:-1])): # Use request.path because we munged app/locale in path_info. newurl = request.path[:-1] if request.GET: with safe_query_string(request): newurl += '?' + request.META['QUERY_STRING'] return HttpResponsePermanentRedirect(newurl) return response