V
V
Vampre2018-11-03 05:19:53
Django
Vampre, 2018-11-03 05:19:53

What is the best way to store Django project settings?

Which is better: to split the settings into different files (local, base, etc.) or use django-environ? What method are you using?
Am I understanding correctly that django-environ suggests creating a .env file for each machine and keeping it out of source control? But then it turns out that in order to make changes to the .env file, for example, for the production version, you need to go to the server and change it there?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yeletsky, 2018-11-03
@Vampre

Splitting settings into different *.py files for different environments is not very convenient.
It is more convenient to have one settings.py that imports settings from some common format (json, ini, etc). In this regard, django-environ can be a convenient solution, but not a must.
You don't need to do this. Although you can keep the configs outside the application repository - in a separate repository with deployment scripts (since not all people who have access to the source should have access to the deployment parameters, and vice versa).
Keeping settings directly in *.py files is inconvenient because, in addition to direct parameter indications, they can also contain different code for preparing them (after all, this is ordinary Python code). When the code is delivered to the servers, such configs are generated one way or another. As a result, development becomes more complicated - it becomes necessary to edit the code both in the *.py file that the developer uses and in the template of the same file that will be used to generate the config on the server. This approach is a direct path to bugs.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question