Python's secrets module has token_hex and a short recipe for generating
random strings:
https://docs.python.org/3.10/library/secrets.html#recipes-and-best-practices
. I don't think Django needs to provide a public function here. I would
advise Digital Ocean to recommend the secrets module.

On Wed, Jun 1, 2022 at 10:22 AM Fab <fabianjarr...@gmail.com> wrote:

> There isn't a recommended way so you can generate it however you want. The
> function is used in the startproject
> <https://github.com/django/django/blob/0dd29209091280ccf34e07c9468746c396b7778e/django/core/management/commands/startproject.py#L19>
>  command
> for convenience.
>
> On Monday, 16 May 2022 at 13:09:36 UTC+1 Sam wrote:
>
>> In the DigitalOcean documentation
>> <https://docs.digitalocean.com/tutorials/app-deploy-django-app/#setting-the-secret-key>
>> I just found that they use
>> `from django.core.management.utils import get_random_secret_key`
>> to generate a new, unique secret key.
>>
>> I didn't know that there was such a function.
>> and the get_random_secret_key function seems to be not documented so far
>> <https://docs.djangoproject.com/en/4.0/ref/utils/>.
>>
>> Is this the recommended way to generate secret keys for Django apps?
>> If that's the case wouldn't it make sense to write a piece of
>> documentation for that?
>>
>> Kind regards,
>> Samuel✌
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/b2018ec8-0cc0-475e-8ede-81f10c1e193bn%40googlegroups.com
> <https://groups.google.com/d/msgid/django-developers/b2018ec8-0cc0-475e-8ede-81f10c1e193bn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAMyDDM2TiTctT9uEL1gvy%3DGo8NfoYmYBUsuOx0LtS5TGgAKdAg%40mail.gmail.com.
  • get... Sam
    • ... Fab
      • ... 'Adam Johnson' via Django developers (Contributions to Django itself)

Reply via email to