Read code for info
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | """
Using the below, you can then issue commands like the following from the shell
DJANGO_ENVIRONMENT=dev /path/to/manage.py shell
DJANGO_ENVIRONMENT=dev /path/to/manage.py runfcgi
etc etc
You can also use this very nicely with supervisord and uwsgi.
ALSO, you can have individual settings based on the local server hostname:
import socket
if socket.gethostname() == 'sws01.internal':
pass
else:
pass
etc etc
"""
#settings.py
# Add this to the top of your settings.py
if not os.environ.has_key('DJANGO_ENVIRONMENT'):
raise Exception, "You must provide environ DJANGO_ENVIRONMENT (dev/staging/prod)"
if not os.environ.get('DJANGO_ENVIRONMENT') in ('dev', 'staging', 'prod'):
raise Exception, "Invalid environment specified, DJANGO_ENVIRONMENT must be (dev/staging/prod)"
if os.environ['DJANGO_ENVIRONMENT']=='dev':
# Enable debug mode
DEBUG = True
TEMPLATE_DEBUG = DEBUG
SHOW_DEBUG_TOOLBAR = True
# Database
DATABASE_NAME = ''
DATABASE_USER = ''
DATABASE_PASSWORD = ''
DATABASE_HOST = ''
DATABASE_PORT = ''
# Celery Broker
BROKER_HOST = "mysql01.internal"
BROKER_PORT = 5672
BROKER_USER = "simplicitymedialtd"
BROKER_PASSWORD = ""
BROKER_VHOST = "cdn06_dev"
# Cache settings
CACHE_BACKEND = 'memcached://hostname:12345/'
if os.environ['DJANGO_ENVIRONMENT']=='staging':
# Enable debug mode
DEBUG = True
TEMPLATE_DEBUG = DEBUG
SHOW_DEBUG_TOOLBAR = True
# Database
DATABASE_NAME = ''
DATABASE_USER = ''
DATABASE_PASSWORD = ''
DATABASE_HOST = ''
DATABASE_PORT = ''
# Celery Broker
BROKER_HOST = "mysql01.internal"
BROKER_PORT = 5672
BROKER_USER = "simplicitymedialtd"
BROKER_PASSWORD = ""
BROKER_VHOST = "cdn06_dev"
# Cache settings
CACHE_BACKEND = 'memcached://hostname:12345/'
if os.environ['DJANGO_ENVIRONMENT']=='prod':
# Enable debug mode
DEBUG = False
TEMPLATE_DEBUG = DEBUG
SHOW_DEBUG_TOOLBAR = True
# Database
DATABASE_NAME = ''
DATABASE_USER = ''
DATABASE_PASSWORD = ''
DATABASE_HOST = ''
DATABASE_PORT = ''
# Celery Broker
BROKER_HOST = "mysql01.internal"
BROKER_PORT = 5672
BROKER_USER = "simplicitymedialtd"
BROKER_PASSWORD = ""
BROKER_VHOST = "cdn06_dev"
# Cache settings
CACHE_BACKEND = 'memcached://hostname:12345/'
|
More like this
- Template tag - list punctuation for a list of items by shapiromatron 10 months, 1 week ago
- JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 10 months, 2 weeks ago
- Serializer factory with Django Rest Framework by julio 1 year, 5 months ago
- Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 6 months ago
- Help text hyperlinks by sa2812 1 year, 6 months ago
Comments
Please login first before commenting.