Skip to content
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

Create empty local_settings.py when none exists to avoid erronious "missing local_settings" warning #21890

Merged
merged 3 commits into from
Feb 26, 2024
Merged
Changes from all 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
18 changes: 7 additions & 11 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,13 @@ def insert_debug_toolbar_middleware(middlewares):

REMOTE_SETTINGS_IS_TEST_SERVER = True

# If you have settings you want to overload, put them in a local_settings.py.
try:
from local_settings import * # noqa
except ImportError:
import traceback
import warnings

warnings.warn(
'Could not import local_settings module. {}'.format(traceback.format_exc()),
stacklevel=1,
)
local_settings_path = path('local_settings.py')

if not os.path.exists(local_settings_path):
with open(local_settings_path, 'w') as file:
file.write('# Put settings you want to overload in this file.\n')

from local_settings import * # noqa

SITEMAP_DEBUG_AVAILABLE = True

Expand Down