Created
February 11, 2013 05:41
-
-
Save hzbd/4752905 to your computer and use it in GitHub Desktop.
Appfog a simple django_setting.py for Postgresql-9.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json, psycopg2 | |
vcap_services = json.loads(os.environ['VCAP_SERVICES']) | |
postgres_srv = vcap_services['postgresql-9.1'][0] | |
try: | |
cred = postgres_srv['credentials'] | |
except KeyError,ke: | |
print >> sys.stderr, "VCAP_SERVICES = %s" % str(vcap_services) | |
raise ke | |
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.postgresql_psycopg2', | |
'NAME': cred['name'], | |
'USER': cred['user'], | |
'PASSWORD': cred['password'], | |
'HOST': cred['hostname'], | |
'PORT': cred['port'], | |
} | |
} | |
... | |
TEMPLATE_DIRS = ( | |
os.path.join(os.path.dirname(__file__), 'templates').replace('\\','/'), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment