[Python] Can SECRET_KEY be set to get_random_secret_key() in Django settings?

Discussão em 'Python' iniciado por Stack, Janeiro 22, 2025.

  1. Stack

    Stack Membro Participativo

    I am wondering whether I can generate a random secret key inside my Django application and assign it to the SECRET_KEY variable, instead of reading it from an environment variables. e.g.

    # settings.py

    from django.core.management.utils import get_random_secret_key

    SECRET_KEY = get_random_secret_key()


    Is this recommended, or bad practice?

    Continue reading...

Compartilhe esta Página