﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
19784	Custom urlconf reset too early	pascal chambon	nobody	"In core/handlers/base.py of django, the ""cleanup"" of customp urlconf, via a urlresolvers.set_urlconf(None),
happens BEFORE response processors are loaded.

That prevents any url resolution in response middlewares, especially it breaks django debug toolbar when it tries to regenerate the template contexts in my project.

I see no reason why response middlewares shouldn't have the same request context as the rest of request processing steps, so would it be possible to place the finally clause to the end, like that ?


{{{

            try:
                # Apply response middleware, regardless of the response
                for middleware_method in self._response_middleware:
                    response = middleware_method(request, response)
                response = self.apply_response_fixes(request, response)
            except: # Any exception should be gathered and handled
                signals.got_request_exception.send(sender=self.__class__, request=request)
                response = self.handle_uncaught_exception(request, resolver, sys.exc_info())

            return response

        finally: ### <<<<< PART PUSHED TO THE VERY END OF REQUEST HANDLING
            # Reset URLconf for this thread on the way out for complete
            # isolation of request.urlconf
            urlresolvers.set_urlconf(None)
}}}
"	Bug	closed	Core (URLs)	1.4	Normal	duplicate	urlconf request		Unreviewed	0	0	0	0	0	0
