Skip to content

Commit 1721361

Browse files
committed
Slightly optimize show_toolbar()
Avoid inspecting the request if `DEBUG` is not `True`, and remove unnecessary cast to `bool`.
1 parent e9724cf commit 1721361

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

debug_toolbar/middleware.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ def show_toolbar(request):
1818
"""
1919
Default function to determine whether to show the toolbar on a given page.
2020
"""
21-
if request.META.get("REMOTE_ADDR", None) not in settings.INTERNAL_IPS:
22-
return False
23-
24-
return bool(settings.DEBUG)
21+
return (
22+
settings.DEBUG
23+
and request.META.get("REMOTE_ADDR", None) in settings.INTERNAL_IPS
24+
)
2525

2626

2727
@lru_cache()

0 commit comments

Comments
 (0)