I have a dev and prod environment, I am trying to programmatically assign the settings module based on an environment variable DEV so fat my settings have the following structure:
project
--settings
----__init__.py
----common.py
----dev.py
----prod.py
inside my __init__.py I have:
import os
if os.environ['DEV_ENV']:
os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings.dev'
else:
os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings.prod'
However, when I run python3 manage.py migrate I get this error:
settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
however if I run with --settings flag manually, it works
python3 manage.py migrate --settings=project.settings.dev