generate 50 characters long for django 1

generate 50 characters long for django

def get_random_secret_key():
    """
    Return a 50 character random string usable as a SECRET_KEY setting value.
    """
    chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
    return get_random_string(50, chars)

Here is what the above code is Doing:
1. It’s importing the get_random_string function from the django.utils.crypto module.
2. It’s defining a function called get_random_secret_key that returns a 50 character random string.
3. It’s calling the get_random_string function, passing in the characters we want it to choose from.

Similar Posts