import sys
1. Database
if ‘runserver’ not in sys.argv:
Production database
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'aaadb',
'USER': 'postgres',
'PASSWORD': 'pass',
'HOST': 'aaadb.cymjfpovl5ev.eu-west-1.rds.amazonaws.com',
'PORT': '5432',
}
}
else:
Local database
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'aaa2',
'USER': 'postgres',
'PASSWORD': 'pass',
'HOST': 'localhost',
'PORT': '',
}
}
2. Debug
if 'runserver' not in sys.argv:
DEBUG = False
else:
DEBUG = True
3. Some debug apps
if 'runserver' in sys.argv:
INSTALLED_APPS += [
'debug_toolbar', # and other apps for local development
]
4. Allowed hosts
if 'runserver' in sys.argv:
ALLOWED_HOSTS += [
'127.0.0.1',
'localhost',
'.example.com',
'vagrant',
'*',
]