Created
November 13, 2015 20:40
-
-
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
This file contains hidden or 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 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