Audvik Labs

Django | Python: How to generate a strong password?

Django comes with a built-in module i.e. BaseUserManager that can be used to generate a random password. Below is a sample implementation of that.

from django.contrib.auth.base_user import BaseUserManager

def random_password(size=12):

    return BaseUserManager().make_random_password(size)

More extended information about the Django can be found here.

Leave a comment

Your email address will not be published. Required fields are marked *