-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Django-debug-toolbar for profiling requests performance #768
Conversation
requirements.txt
Outdated
@@ -82,4 +82,4 @@ wcwidth==0.1.9 | |||
Werkzeug==1.0.0 | |||
whitenoise==5.0.1 | |||
zipp==3.1.0 | |||
|
|||
django-debug-toolbar==2.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to move this into requirements/dev.in and compile it with pip-compile requirements/dev.in
posthog/settings.py
Outdated
@@ -85,7 +85,8 @@ def get_env(key): | |||
'rest_framework', | |||
'loginas', | |||
'corsheaders', | |||
'social_django' | |||
'social_django', | |||
'debug_toolbar' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
b/c of the below comment, this package won't always be here. Could do something like
try:
import debug_toolbar
INSTALLED_APPS.append('debug_toolbar')
MIDDLEWARE.append('debug_toolbar.middleware.DebugToolbarMiddleware')
except ImportError:
pass
posthog/urls.py
Outdated
@@ -180,11 +180,14 @@ def logout(request): | |||
] | |||
|
|||
if settings.DEBUG: | |||
import debug_toolbar # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably have the same try/except pattern in case someone uses DEBUG to debug live and hasn't installed debug_toolbarr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds safe
posthog/settings.py
Outdated
|
||
# Load debug_toolbar if we can (DEBUG and Dev modes) | ||
try: | ||
import debug_toolbar # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be easier to just add the module to mypy.ini
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea
Changes
Really helps figure out what Django is trying to do on the backend and if it's the DB that's the problem or the app.
This is only enabled when
DEBUG
is TrueChecklist