Create empty local_settings.py when none exists to avoid erronious "missing 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>
This commit is contained in:
Kevin Meinhardt 2024-02-26 09:13:35 +01:00 коммит произвёл GitHub
Родитель 369125c18a
Коммит 10fe3e19d5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 6 добавлений и 10 удалений

Просмотреть файл

@ -132,17 +132,13 @@ CUSTOMS_API_KEY = 'customssecret'
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
local_settings_path = path('local_settings.py')
warnings.warn(
'Could not import local_settings module. {}'.format(traceback.format_exc()),
stacklevel=1,
)
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