Skip to content

Commit

Permalink
Create empty local_settings.py when none exists to avoid erronious "m…
Browse files Browse the repository at this point in the history
…issing local_settings" warning (#21890)

* Create empty local_settings.py if none exsits

* Update settings.py

Co-authored-by: Mathieu Pillard <diox@users.noreply.github.com>

* Format code

---------

Co-authored-by: Mathieu Pillard <diox@users.noreply.github.com>
  • Loading branch information
KevinMind and diox committed Feb 26, 2024
1 parent 369125c commit 10fe3e1
Showing 1 changed file with 7 additions and 11 deletions.
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

0 comments on commit 10fe3e1

Please sign in to comment.