Skip to content

Instantly share code, notes, and snippets.

@cocomatias
Last active June 11, 2021 18:05
Show Gist options
  • Save cocomatias/c8f1c9e9dc57309fe8c9665be8665d1e to your computer and use it in GitHub Desktop.
Save cocomatias/c8f1c9e9dc57309fe8c9665be8665d1e to your computer and use it in GitHub Desktop.
Django Rest, Postgres ( Travis CI ) DATABASES settings
# Database
import dj_database_url
POSTGRES_URL = "HEROKU_POSTGRESQL_PURPLE_URL" # The name of your Heroku Postgres database URL
if 'DATABASES' not in locals():
DATABASES = {}
DATABASES['default'] = dj_database_url.config(default='postgres://POSTGRES_USERNAME:POSTGRES_PASSWORD@localhost:5432/POSTGRES_DATABASE_NAME')
if POSTGRES_URL in os.environ:
DATABASES = {}
DATABASES['default'] = dj_database_url.config(default=os.environ[POSTGRES_URL])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment