From 020742f26373283f694304900b10c01963d2a77a Mon Sep 17 00:00:00 2001 From: Kevin Meinhardt Date: Tue, 20 Feb 2024 12:27:20 +0100 Subject: [PATCH 1/3] Create empty local_settings.py if none exsits --- settings.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/settings.py b/settings.py index 11378a8d01db..e7a833bfd90d 100644 --- a/settings.py +++ b/settings.py @@ -132,17 +132,16 @@ 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( + '# If you have settings you want to overload,' + 'put them in a local_settings.py.\n' + ) + +from local_settings import * # noqa SITEMAP_DEBUG_AVAILABLE = True From 11f6de6eced08ba9a5a41071449fd609e8973744 Mon Sep 17 00:00:00 2001 From: Kevin Meinhardt Date: Wed, 21 Feb 2024 12:59:08 +0100 Subject: [PATCH 2/3] Update settings.py Co-authored-by: Mathieu Pillard --- settings.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/settings.py b/settings.py index e7a833bfd90d..4b743844becd 100644 --- a/settings.py +++ b/settings.py @@ -137,8 +137,7 @@ def insert_debug_toolbar_middleware(middlewares): if not os.path.exists(local_settings_path): with open(local_settings_path, 'w') as file: file.write( - '# If you have settings you want to overload,' - 'put them in a local_settings.py.\n' + '# Put settings you want to overload in this file.\n' ) from local_settings import * # noqa From 9300577a7e10bc541901aeb150b1455934c7ae83 Mon Sep 17 00:00:00 2001 From: Kevin Meinhardt Date: Fri, 23 Feb 2024 09:30:17 +0100 Subject: [PATCH 3/3] Format code --- settings.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/settings.py b/settings.py index 4b743844becd..c7e931c78828 100644 --- a/settings.py +++ b/settings.py @@ -136,9 +136,7 @@ def insert_debug_toolbar_middleware(middlewares): 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' - ) + file.write('# Put settings you want to overload in this file.\n') from local_settings import * # noqa