Django use settings.py elsewhere

I am having problems running Django with settings.py options elsewhere

I have a folder setting with test.py as a copy of settings.py

The folder is laid out as

   models.py
   settings.py
   setting/
       test.py

this one works with default value

SetEnv DJANGO_SETTINGS_MODULE myproject.settings

python manage.py syncdb  --settings="myproject.settings"

this does not work if tring use the file in a subdirectory

SetEnv DJANGO_SETTINGS_MODULE myproject.setting.test

python manage.py syncdb  --settings="myproject.setting.test"

Mistake

Error: Could not import settings 'myproject.setting.test' (Is it on sys.path? 
Does it have syntax errors?): No module named setting.test
+3
source share
2 answers

It seems to me that your directory settingneeds a file __init__.py, so it is a valid Python package .

+8
source

settings.py , settings.py init.py ,

   models.py
   settings/
           __init__.py
           test.py
+1

Source: https://habr.com/ru/post/1725403/


All Articles