Last active
August 29, 2015 14:18
-
-
Save SafeEval/3a86e401db8e0311ba12 to your computer and use it in GitHub Desktop.
Generate a SECRET_KEY for Django via CLI
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
# Generates and prints a new SECRET_KEY for Django to STDOUT. | |
# Run directly from the command line without requiring a script file. | |
python -c "import random; import string; print (''.join( [random.SystemRandom().choice(string.digits + string.ascii_letters + string.punctuation).replace('\"', '').replace('\'','') for i in range(100)] ))" | |
# Environment variable example. | |
# $ export SECRET_KEY=$(python -c "import random; import string; print (''.join( [random.SystemRandom().choice(string.digits + string.ascii_letters + string.punctuation).replace('\"', '').replace('\'','') for i in range(100)] ))") | |
# Heroku example. | |
# $ heroku config:set SECRET_KEY=$(python -c "import random; import string; print (''.join( [random.SystemRandom().choice(string.digits + string.ascii_letters + string.punctuation).replace('\"', '').replace('\'','') for i in range(100)] ))") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment