Must my django secret key be 50 chars long

Viewed 192

I thought the secret key was just something like a password, so I changed it. Now I found out that it is used to make hashes and that kind of stuff. So can I just type anything I want in the secret key field, or is a special algorythm needed?

And must my secret key be 50 chars long or can it be of any length?


Thx for your help and stay healthy!

1 Answers

according to Django docs and security checks:

security.W009: Your SECRET_KEY has less than 50 characters, less than 5 unique characters, or it’s prefixed with 'django-insecure-' indicating that it was generated automatically by Django. Please generate a long and random SECRET_KEY, otherwise many of Django’s security-critical features will be vulnerable to attack

So, Your SECRET_KEY should be at least 50 characters in length and could contain a random mix of letters, digits, and symbols.

But plz keep in mind, that for special characters (e.g. hash mark #) you may face issues in Virtual environments, like this one. So the best practice is to generate SECRET_KEY with special tools, e.g. Django Extensions with a command generate_secret_key

Related