Skip to content

Commit a166c30

Browse files
NielkStim-schilling
authored andcommitted
Support for request-level urlconf overrides
Middlewares can override the default urlconf per request by setting a "urlconf" attribute to the inbound HttpRequest instance (doc: https://docs.djangoproject.com/en/3.2/ref/request-response/#django.http.HttpRequest.urlconf ) This change adds support for this kind of override
1 parent 15a581d commit a166c30

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

debug_toolbar/toolbar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def is_toolbar_request(cls, request):
146146
# The primary caller of this function is in the middleware which may
147147
# not have resolver_match set.
148148
try:
149-
resolver_match = request.resolver_match or resolve(request.path)
149+
resolver_match = request.resolver_match or resolve(request.path, getattr(request, 'urlconf', None))
150150
except Resolver404:
151151
return False
152152
return resolver_match.namespaces and resolver_match.namespaces[-1] == app_name

0 commit comments

Comments
 (0)