Created
January 15, 2014 20:50
-
-
Save electroniceagle/8444359 to your computer and use it in GitHub Desktop.
This code snippet takes a Django secret from an environment variable or generates a random one automatically exactly once for testing. This hasn't been tested with multiple processes, so might not work as expected in a situation such as running a Celery daemon.
This file contains 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
# use secret from environment or make a random one exactly once | |
SECRET_KEY = os.environ.get( | |
'DJANGO_SECRET', | |
os.environ.update({ | |
'DJANGO_SECRET': ''.join([random.SystemRandom().choice( | |
string.digits + string.letters + string.punctuation) | |
for i in range(50)])})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment