Is there a function for generating settings.SECRET_KEY in django? : <p>I wrote an <a href="https://github.com/nemesisdesign/ansible-openwisp2/" rel="noreferrer">ansible-role for openwisp2</a> to ease its deployment, it's a series of django apps. To ease the deployment as much as possible, I wrote a simple (probably trivial) <a href="https://github.com/nemesisdesign/ansible-openwisp2/blob/master/files/generate_django_secret_key.py" rel="noreferrer">SECRET_KEY generator script</a> which is called by ansible to generate the secret key the first time the ansible playbook is run.</p>

<p>Now, that works fine BUT I think it defeats the built-in security measures Django has in generating a strong key which is also very hard to guess.</p>

<p>At the time I looked at other ways of doing it but didn't find much, now I wonder: <strong>is there a function for generating settings.SECRET_KEY in django?</strong></p>

<p>That would avoid this kind of home baked solutions that even though they work they are not effective when it comes to security.</p>
