Skip to content

Instantly share code, notes, and snippets.

@trey
Created January 19, 2009 05:09
Show Gist options
  • Save trey/48879 to your computer and use it in GitHub Desktop.
Save trey/48879 to your computer and use it in GitHub Desktop.
Do the Django Settings Shuffle.
# You can avoid this shuffle if you do something like this:
#
# You should only use this technique with private projects,
# since your passwords will be in source control for everyone to see.
hostname = os.uname()[1].lower()
if hostname in ['something.dev']:
# Development settings
elif hostname in ['something_else.com', 'and_another.com']:
# Staging settings
else:
# Production settings
DEBUG = True
TEMPLATE_DEBUG = True
DATABASE_ENGINE = 'sqlite3'
DATABASE_NAME = 'dev.db'
# This file on your development machine should have this:
from dev_settings import *
# This file on your production machine should have this:
from production_settings import *
DEBUG = False
TEMPLATE_DEBUG = False
ADMINS = (
('Your Name', 'you@yourdomain.com'),
)
MANAGERS = ADMINS
DATABASE_ENGINE = 'mysql'
DATABASE_NAME = ''
DATABASE_USER = ''
DATABASE_PASSWORD = ''
DATABASE_HOST = 'localhost'
DATABASE_PORT = ''
# ...
try:
from local_settings import *
except ImportError:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment