Last active
March 5, 2025 14:49
-
-
Save sandervm/2b15775012685553f0e2 to your computer and use it in GitHub Desktop.
Generate Django secret key commandline
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
$ python -c 'import random; print "".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") for i in range(50)])' |
Лучше бы ты написал как из SECRET_KEY сгенерировать куку
This is how django does it internally, translated into bash...
KEY=$(chars='abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'; python -c "import secrets; print(''.join(secrets.choice('${chars}') for i in range(50)))")
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@halfprisoner 'SECRET_KEY ' there is a trailing white space in your env variable
Also, how did you store the random key generated above into a variable before passing it as an env variable in the docker run of your project?