Skip to content

Instantly share code, notes, and snippets.

@hzbd
Created February 11, 2013 05:41
Show Gist options
  • Save hzbd/4752905 to your computer and use it in GitHub Desktop.
Save hzbd/4752905 to your computer and use it in GitHub Desktop.
Appfog a simple django_setting.py for Postgresql-9.1
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