There is a lot of settings variables which are a Value type object so we should be able to set their value either from a dotenv file or environment variable.
However it has been badly used on almost all of these settings. We currently do something like this:
The environ_name is causing the issue, if we set DJANGO_SECRET_KEY=foo in dotenv file, the setting value is still ***TOPSECRET***. It seems the code from django-configurations expect a var DJANGO_DJANGO_SECRET_KEY
But if we define it like this:
SECRET_KEY = values.Value("***TOPSECRET***")
When we set DJANGO_SECRET_KEY=foo in dotenv file, the setting value becomes foo.
Not sure actually if adding environ_prefix=None to settings will be enough to fix issue without removing environ_name. However this will add more typo in settings, i tend to prefer to get ride of environ_name because in fact at 90% the current names are the same automatically expected without any environ_** attribute.
Finally, when debugging i found we did some things that are bad practices we should remove:
The DOTENV setting for the dotenv file path MUST only be either as class attribute or defined in pre_setup BEFORE the super().pre_setup(). In setup or post_setup, it will be ignore.
Using super().METHOD in setup methods may not been efficient. As the documentation describe it, it should be super(THECLASS, cls).METHOD;
Todo
[x] Remove all environ_name from Value settings;
[x] Define DOTENV from pre_setup only;
[x] Fix all the super().[setup method] everywhere;
[x] Fix dotenv sample file which use space as separator instead of , as we define in our settings ListValue fields;
There is a lot of settings variables which are a Value type object so we should be able to set their value either from a dotenv file or environment variable.
However it has been badly used on almost all of these settings. We currently do something like this:
The environ_name is causing the issue, if we set
DJANGO_SECRET_KEY=foo
in dotenv file, the setting value is still***TOPSECRET***
. It seems the code from django-configurations expect a varDJANGO_DJANGO_SECRET_KEY
But if we define it like this:
When we set
DJANGO_SECRET_KEY=foo
in dotenv file, the setting value becomesfoo
.Not sure actually if adding
environ_prefix=None
to settings will be enough to fix issue without removingenviron_name
. However this will add more typo in settings, i tend to prefer to get ride ofenviron_name
because in fact at 90% the current names are the same automatically expected without anyenviron_**
attribute.Finally, when debugging i found we did some things that are bad practices we should remove:
pre_setup
BEFORE thesuper().pre_setup()
. Insetup
orpost_setup
, it will be ignore.super().METHOD
in setup methods may not been efficient. As the documentation describe it, it should besuper(THECLASS, cls).METHOD
;Todo
super().[setup method]
everywhere;,
as we define in our settings ListValue fields;