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:
Родитель
369125c18a
Коммит
10fe3e19d5
16
settings.py
16
settings.py
|
@ -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
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче