-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Admin: install debug_toolbar
#9753
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
Conversation
This application needs to be installed if we want to enable it later in the `web-extra` instance. Otherwise, it fails due the static files are not in the manifest. By installing it by default, `collectstatic` will find this application and copy these static files and add them in the manifest. Note this application will only be used if `SHOW_DEBUG_TOOLBAR=True`, which is `False` by default.
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.
I'm not familiar with exactly what debug-toolbar adds, but is there any concerns of parts of debug-toolbar leaking out to the prod application? I'll defer to you all here, but I'm guessing the added views/URLs are the largest concern, which we'd avoid in prod already.
It does seems a little odd to need this on prod, but the only other solution would be doing a collectstatic for prod and a separate collectstatic just for web-extra?
I think installing an app without adding middlewares or URLs is safe. Isn't it?
I thought about this, but... I suppose this could break since web-extra may not have the same applications installed than regular webs and then those static files won't be available for web. |
This is a good question. Looking at the application initialization, it does have side effects: https://github.com/jazzband/django-debug-toolbar/blob/main/debug_toolbar/apps.py#L17 This seems to start initialization of the "panels". I'm not familiar enough with debug-toolbar internals to answer if this has zero side-effects without the middleware. |
I'm guessing there won't be anything we can do that makes me feel 100% okay with installing debug applications in prod. If anyone else wants to overrule me here, I'll defer to anyone with more background on debug-toolbar. |
Another option could be to do something like:
That way we will install it only when running |
Hah nice! If it's possible to do that, that does seem fine. I think as long as the prod web process doesn't evaluate debug toolbar, we're safe 👍 |
In which cases are we running What I mean:
|
We run So, we need to have |
Use a "staticfiles finder" to find static files from an app that's not installed in Django when running `collectstatic`. This method is less intrusive and safe to run on production since it does not execute `debug_toolbar` code on `web` instances.
I changed the pattern here for a safer one. I created a "static files finder" to always copy the static files from I tested it locally, and I ended up with the |
This sounds like a great solution 👍 |
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.
Oooo, this is a really nice solution 💯
This seems much safer 👍
The docs-dev is failing, but I haven't change anything related to that, so 🤷🏼 . I'm merging this PR because we need it for today's deploy. We can come back later and fix the docs issue. |
* Admin: install `debug_toolbar` This application needs to be installed if we want to enable it later in the `web-extra` instance. Otherwise, it fails due the static files are not in the manifest. By installing it by default, `collectstatic` will find this application and copy these static files and add them in the manifest. Note this application will only be used if `SHOW_DEBUG_TOOLBAR=True`, which is `False` by default. * Copy static files from `debug_toolbar` even when it's not installed Use a "staticfiles finder" to find static files from an app that's not installed in Django when running `collectstatic`. This method is less intrusive and safe to run on production since it does not execute `debug_toolbar` code on `web` instances. * pre-commit linting * Linting issue fixed
* Admin: install `debug_toolbar` This application needs to be installed if we want to enable it later in the `web-extra` instance. Otherwise, it fails due the static files are not in the manifest. By installing it by default, `collectstatic` will find this application and copy these static files and add them in the manifest. Note this application will only be used if `SHOW_DEBUG_TOOLBAR=True`, which is `False` by default. * Copy static files from `debug_toolbar` even when it's not installed Use a "staticfiles finder" to find static files from an app that's not installed in Django when running `collectstatic`. This method is less intrusive and safe to run on production since it does not execute `debug_toolbar` code on `web` instances. * pre-commit linting * Linting issue fixed
As noted in #9791: I was going through our PRs since #9734 and this is one of the few PRs that doesn't change our docs. It didn't, however, skip the documentation build: https://readthedocs.org/projects/dev/builds/18765036/ But it did contain the feature: readthedocs.org/.readthedocs.yml Line 26 in 8ca4257
|
This application needs to be installed if we want to enable it later in the
web-extra
instance. Otherwise, it fails due the static files are not in the manifest.By installing it by default,
collectstatic
will find this application and copy these static files and add them in the manifest.Note this application will only be used if
SHOW_DEBUG_TOOLBAR=True
, which isFalse
by default.