Я использую подход, при котором мои настройки на самом деле являются пакетом, а не модулем
Настройки /
INIT .py
base.py
local.py # этот находится на .gitignore
* INIT 1008 * .py:
from setings import *
try:
from local.py import *
except ImportError:
pass
base.py:
import os
DEBUG = False
TEMPLATE_DEBUG = DEBUG
SITE_ROOT = os.path.join( os.path.dirname( os.path.realpath(__file__) ) ,'..' )
ADMINS = (
# ('Your Name', 'your_email@example.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
etc...
local.py:
from settings import settings as PROJECT_DEFAULT
PREPEND_WWW = False
DEBUG = True
TEMPLATE_DEBUG = DEBUG
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_pyscopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'somesecretname', # Or path to database file if using sqlite3.
'USER': 'somesecretuser', # Not used with sqlite3.
'PASSWORD': 'somesecretpassword', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
INSTALLED_APPS += PROJECT_DEFAULT.INSTALLED_APPS + ('debug_toolbar',)
Вы можете увидеть пример этого в здесь