Skip to content

Instantly share code, notes, and snippets.

@bergantine
Last active June 24, 2022 14:02
Show Gist options
  • Select an option

  • Save bergantine/4035311 to your computer and use it in GitHub Desktop.

Select an option

Save bergantine/4035311 to your computer and use it in GitHub Desktop.
Django: Specify Test Database. #django #test #database
# Useful if dev settings are pointed at the production or staging database on a remote host
# In the dev settings, after the `DATABASES` configuration, add a second wrapped in an `if` statement
import sys
if 'test' in sys.argv:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'django_db',
'USER': 'django_login',
'PASSWORD': 'secret',
'HOST': '',
'PORT': '',
}
}
@abotte
Copy link

abotte commented Apr 17, 2019

Evil but working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment