vendredi 18 juin 2021

Better ways to generate codes in django (python)

I am working on an authentication project where I am applying different features like email verification, password reset and these features rely on emails.

Now i want to send a code to the user through an email and verify that on the backend.

Now to generate the code(5-digit), this is what i did;

import random
code = random.randint(10000, 99999)
print(code)

I just want to know is this a better way to do so. Are there any drawbacks or just fine.




Aucun commentaire:

Enregistrer un commentaire