Changes settings file according to server hostname.
1 2 3 4 5 6 7 8 9 10 11 12 | import socket, platform
hostname = socket.gethostname().replace('.','_').replace('-', '_')
try:
import os
path = "settings_files/%s.py" % hostname
path = os.path.join(os.path.dirname(__file__), path)
execfile(path)
except ImportError, e:
import sys
sys.stderr.write("Unable to read settings_files/%s.py\n" % hostname)
sys.exit(1)
|
More like this
- Add Toggle Switch Widget to Django Forms by OgliariNatan 1 day, 18 hours ago
- get_object_or_none by azwdevops 3 months, 3 weeks ago
- Mask sensitive data from logger by agusmakmun 5 months, 2 weeks ago
- Template tag - list punctuation for a list of items by shapiromatron 1 year, 7 months ago
- JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 1 year, 8 months ago
Comments
A variation:
Lets you use shorter names - for example, mysite.py for mysite.com.au, or www_mysite.py for www.mysite.com.
#
Please login first before commenting.