I'm using django-configurations in my solution to separate dev settings from prod. As part of that in dev, I modify the manage.py as follows:
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
os.environ.setdefault('DJANGO_CONFIGURATION', 'Dev')
from configurations.management import execute_from_command_line
execute_from_command_line(sys.argv)
And I use environment variables to override. I made the same pages to my PA which has a few more values for production.
import os
import sys
from configurations.management import execute_from_command_line
os.environ['AWS_ACCESS_KEY_ID'] = '<SNIP>'
os.environ['AWS_SECRET_ACCESS_KEY'] = '<SNIP>'
os.environ['DJANGO_SECRET_KEY='] = '<SNIP>'
os.environ['DJANGO_SETTINGS_MODULE'] = 'core.settings'
os.environ['DJANGO_CONFIGURATION'] = 'Prod'
execute_from_command_line(sys.argv)
But when I refresh my web app, I get the following error:
Error running WSGI application
django.core.exceptions.ImproperlyConfigured: Configuration cannot be imported, environment variable DJANGO_CONFIGURATION is undefined.
Any ideas what I'm doing wrong here? I did pip install django-configurations. I also made the same environment variables in /postactive and they work.
Thanks a lot for the help!