Django's boilerplate project generates a SECRET_KEY for you, but it's kind of annoying when you need to generate another one and there's no easy way. You could generate really any password, but it's nice if you can use Django's built in function to do this.

Django must be installed.

$ pip3 install django

Now you can just enter this command.

$ python3 -c "from import get_random_secret_key; print(get_random_secret_key())"

It will spit back a SECRET_KEY at you.

Better yet, turn this into an alias so you can call it at any time. Edit ~/.bashrc and put this at the bottom.

alias djkeygen="python3 -c 'from import get_random_secret_key; print(get_random_secret_key())'"

Now you can run the command djkeygen from anywhere to get the SECRET_KEY. (Note: you'll have to open a new terminal window before this takes effect.)