Currently I have this in my settings.py
file:
DEBUG = True
LOCAL = True
TEMPLATE_DEBUG = DEBUG
SITE_TITLE = 'Stack Overflow Question'
REMOTE_SITE_URL = "http://************:8080"
LOCAL_SITE_URL = "http://************:8000"
ADMINS = (
# ('Your Name', '[email protected]'),
)
MANAGERS = ADMINS
if LOCAL:
SITE_URL = LOCAL_SITE_URL
ROOT_URL = '/mnt/hgfs/Sites/************'
engine = 'sqlite3'
dbName = '************.db'
dbUser = ''
dbPassword = ''
dbHost = ''
dbPort = ''
else:
SITE_URL = REMOTE_SITE_URL
ROOT_URL = '/var/www/vhosts/www.*************.com/public/'
engine = 'mysql'
dbName = '************'
dbUser = 'www-data'
dbPassword = '************'
dbHost = ''
dbPort = ''
The idea is that if I modify LOCAL=True
to false, I can switch between the sqlite3
database and the mysql
that's kept on the server. But this is cumbersome when using SVN. What I want is the ability for settings.py
to intelligently know if it's on the server or running locally. Is there a way to sniff the URL, IP or simply check a file that exists on the server and not locally? Not only am I looking for a solution, but one that doesn't tax the server. Checking if a file exists might be a bit heavy of a process if it occurs every time Django renders a page. Any suggestions?