Am 03.03.22 um 04:43 schrieb Adeyemi Deji:
> What do u mean by on installation @On installation, the file is then copied to localconfig.py, where it is *ignored* by svn, git, etc. The file is then customized for production, development, …
>
> Do u mean during deployment?
During development, you create two files:
localconfig.example
This file contains only example data, comments/instructions and *irrelevant* data, such as *fake* secret keys, fake database passwords, etc. This file is committed to the repository. Its *only* purpose is to serve as an example and be copied to filename localconfig.py later.
localconfig.py
Created from a copy of localconfig.example, during development you must make sure that this file is never committed to your repository. This is achieved by telling the repository to ignore it, e.g. Git by editing the .gitignore file appropriately, Subversion with the svn:ignore property. Still during development, you customize the file as needed for development, i.e. insert the required database details, DEBUG = True, etc.
For deployment, when you first clone the repository on the production server, it will come with the localconfig.example file, but not with the localconfig.py file, as intended. As part of the installation, you copy localconfig.example to localconfig.py and customize it for production (production database, etc.). Done.
Variants of this approach are possible, e.g. keeping the localconfig.py file entirely outside of the project directory, where it is in even less danger to be accidentally committed. Or to store the values not in a py, but in a json, ini, txt, ... file that is loaded and parsed in settings.py.
Best regards,
Carsten