TLDR: Generate Django Secret Key
Raise your hand if you never versioned the Django’s
SECRET_KEY at the beginning of a project and needed to generate a new one before going to production.
This TLDR is a quick reminder of how to generate a secret key locally, without going to some website on the internet to generate it for you.
Django generates a secret key every time that you create a new project, sou this function already exists at its code, and you can access it in this way:
from django.core.management.utils import get_random_secret_key print(get_random_secret_key())
If you don’t even want to have the work of stating the Python shell, you can execute this command on the terminal:
python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())'
Remember that you need Django installed at the environment to run this command.
This work is licensed under a Creative Commons Attribuition-ShareAlike 4.0 International License .