Skip to content

Instantly share code, notes, and snippets.

@tuatara
Created November 13, 2015 20:40
Show Gist options
  • Save tuatara/85d92dd4c168237e71c6 to your computer and use it in GitHub Desktop.
Save tuatara/85d92dd4c168237e71c6 to your computer and use it in GitHub Desktop.
Use active git branch in Django’s DATABASES['NAME'] setting to help manage conflicting state
import subprocess
dbname = 'mydbname.{}.db'.format(
subprocess.check_output(['git', 'symbolic-ref', '--short', 'HEAD',]).rstrip()
)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': path.join(BASE_DIR, dbname),
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment