T
T
tytar2016-05-04 16:50:35
Django
tytar, 2016-05-04 16:50:35

How to properly store settings in a django project?

How to properly store settings in a growing django project When the project is already growing from one file with settings (settings\prod\deb\base etc.), it becomes necessary to categorize the settings into different files, depending on the environment, for example, db. py is different for prod\dev\test
There was a need for a settings manager that is easy and convenient to work with.
Are there any modules to solve such problems? Searching on https://pypi.python.org/pypi didn't turn up a good option

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sim3x, 2016-05-04
@sim3x

categorize settings
There was never such a need
settings1.py
settings.py
myprog
├── manage.py
└── myprog
    ├── __init__.py
    ├── settings
    │   ├── __init__.py
    │   ├── global.py
    │   └── settings_test.py
    ├── urls.py
    └── wsgi.py

__init__.py
import os

if os.environ['test']:
    from settings_test.py import *

global.py/main.py/...
settings_test.py
from global.py import *

foo='buzz'

A
Anatoly Scherbakov, 2016-05-04
@Altaisoft

your_project_root/your_project_name/settings/
├── base.py
├── development.py
├── __init__.py
├── local.py
├── production.py
└── testing.py

base.py - global settings
testing.py - test server
production.py - production server
local.py is ignored by VCS and contains a link to the actual settings file + adjustments necessary, say, for this particular developer, say access to his local DBMS:
from .testing import *
DATABASES = ...

And that's it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question