I have a strange problem when deploying.
For deploying I set the environment variables via file and an export:
production.conf
DJANGO_CONFIGURATION=“Prod”
DJANGO_SECRET_KEY=“abc”
DJANGO_DATABASE_URL=“mysql://testuser:testpwd@localhost/testdb”export $(cat production.conf | xargs)
After python3 manage.py makemigrations I get the following error messages:
Traceback (most recent call last):
File “/home/testuser/test/manage.py”, line 23, in
main()
File “/home/testuser/test/manage.py”, line 19, in main
execute_from_command_line(sys.argv)
File “/home/testuser/test-venv/lib/python3.10/site-packages/django/core/management/init.py”, line 446, in execute_from_command_line
utility.execute()
File “/home/testuser/test-venv/lib/python3.10/site-packages/django/core/management/init.py”, line 386, in execute
settings.INSTALLED_APPS
File “/home/testuser/test-venv/lib/python3.10/site-packages/django/conf/init.py”, line 92, in getattr
self._setup(name)
File “/home/testuser/test-venv/lib/python3.10/site-packages/django/conf/init.py”, line 79, in _setup
self._wrapped = Settings(settings_module)
File “/home/testuser/test-venv/lib/python3.10/site-packages/django/conf/init.py”, line 190, in init
mod = importlib.import_module(self.SETTINGS_MODULE)
File “/usr/lib/python3.10/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1050, in _gcd_import
File “”, line 1027, in _find_and_load
File “”, line 1006, in _find_and_load_unlocked
File “”, line 672, in _load_unlocked
File “”, line 632, in _load_backward_compatible
File “/home/testuser/test-venv/lib/python3.10/site-packages/configurations/importer.py”, line 153, in load_module
reraise(err, "Couldn’t find configuration ‘{0}’ "
File “/home/testuser/test-venv/lib/python3.10/site-packages/configurations/utils.py”, line 65, in reraise
raise exc
File “/home/testuser/test-venv/lib/python3.10/site-packages/configurations/importer.py”, line 151, in load_module
cls = getattr(mod, self.name)
’ . Did you mean: ‘Prod’?module ‘test.settings’ has no attribute 'Prod
If I enter the value of the environment variable DJANGO_CONFIGURATION manually, everything is ok.
DJANGO_CONFIGURATION=“Prod”
export DJANGO_CONFIGURATIONpython3 manage.py makemigrations
No changes detected
The value of the environment variable DJANGO_DATABASE_URL does not cause any problem, only DJANGO_CONFIGURATION.
I was thinking of an encoding problem, but that’s probably out of the question. Also because env always shows the same values for DJANGO_CONFIGURATION. But the same value is obviously not the same for Django after all.
Does anyone have an explanation for this?