sveetch / cookiecutter-bireli

A Cookiecutter template to produce a modern Django site project
https://cookiecutter-bireli.readthedocs.io/
MIT License
1 stars 0 forks source link

Settings value are not overriden from dotenv or environment variables #24

Closed sveetch closed 1 year ago

sveetch commented 1 year ago

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:

SECRET_KEY = values.Value("***TOPSECRET***", environ_name="DJANGO_SECRET_KEY")

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:

Todo

sveetch commented 1 year ago

Done in 0.3.3-pre.8

sveetch commented 1 year ago

Finally changed DOTENV definition, moved it to django builtin setting since it can not be properly done from environment settings