Skip to content

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

Merged
merged 4 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions readthedocs/core/finders.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import os

from debug_toolbar.apps import DebugToolbarConfig
from django.contrib.staticfiles.finders import AppDirectoriesFinder


class DebugToolbarFinder(AppDirectoriesFinder):

"""
Finder to copy the static files for `debug_toolbar` even if it's not installed.

We want to do this because we run `collectstatic` from `web` instance
which does not have `debug_toolbar` installed.
Then, when running the `admin` instance from `web-extra` with `debug_toolbar` installed,
if fails because it does not find the static files.

By forcing collecting these static files even when `debug_toolbar` is not installed,
we avoid this issue when running the `admin` instance.
"""

def __init__(self, app_names=None, *args, **kwargs):
app_config = DebugToolbarConfig.create('debug_toolbar')
self.apps = [app_config.name]
self.storages = {
app_config.name: self.storage_class(
os.path.join(
app_config.path,
self.source_dir,
)
)
}
1 change: 1 addition & 0 deletions readthedocs/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ def MIDDLEWARE(self):
STATICFILES_FINDERS = [
'readthedocs.core.static.SelectiveFileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'readthedocs.core.finders.DebugToolbarFinder',
]
PYTHON_MEDIA = False

Expand Down