Home > Article > Backend Development > How to Manage Django Settings for Local Development and Production?
Managing Django settings across local development and production environments can be a challenge. Some settings, such as constants, can be shared between both while others, like file paths, require variation.
The recommended approach, as outlined in "Two Scoops of Django," is to employ version control and store settings in a dedicated directory within your project:
project/ app1/ app2/ project/ __init__.py settings/ __init__.py base.py local.py production.py manage.py
Common Settings in base.py
settings/base.py houses settings shared across both environments, such as MEDIA_ROOT and ADMIN.
Site-Specific Settings
Executing Django with Specified Settings
When running Django commands, utilize the --settings option to specify the appropriate settings file:
Sample Project Template
For further guidance, a sample project layout template is available on GitHub.
The above is the detailed content of How to Manage Django Settings for Local Development and Production?. For more information, please follow other related articles on the PHP Chinese website!