Skip to content

Instantly share code, notes, and snippets.

@jarshwah
Created May 2, 2011 00:29
Show Gist options
  • Save jarshwah/951034 to your computer and use it in GitHub Desktop.
Save jarshwah/951034 to your computer and use it in GitHub Desktop.
Being explicit with django local settings
// Being explicit with which settings file is used, allows two important properties. settings.py is ALWAYS in a production ready state, even if 'settingslocal' is accidentally checked into source control. The other nice side effect, is that every developers settings files are stored in source control - allowing each developer to share components of their settings files with their peers.
// runserver
python manage.py runserver --settings settingsjosh
// syncdb
python manage.py syncdb --settings settingsjosh
// syncdb production
python manage.py syncdb
from os import path
SITE_ROOT = path.dirname(path.realpath(__file__))
DEBUG = False
TEMPLATE_DEBUG = False
ADMINS = (
('Josh Smeaton', '[email protected]'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': '*******',
'USER': '********',
'PASSWORD': '*******',
'HOST': '**********',
'PORT': '****',
},
}
# all other global settings
from settings import *
DEBUG = True
TEMPLATE_DEBUG = True
SQLITE_DB_PATH = path.join(SITE_ROOT, 'db/josh.db')
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': SQLITE_DB_PATH, # 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.
}
}
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
}
}
INSTALLED_APPS += ('debug_toolbar',)
INTERNAL_IPS = ('127.0.0.1',)
DEBUG_TOOLBAR_PANELS = (
'debug_toolbar.panels.version.VersionDebugPanel',
'debug_toolbar.panels.timer.TimerDebugPanel',
'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
'debug_toolbar.panels.headers.HeaderDebugPanel',
'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
'debug_toolbar.panels.template.TemplateDebugPanel',
'debug_toolbar.panels.sql.SQLDebugPanel',
'debug_toolbar.panels.signals.SignalDebugPanel',
'debug_toolbar.panels.logger.LoggingPanel',
)
EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
EMAIL_FILE_PATH = path.join(SITE_ROOT, 'emails/')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment