DEV Community

Cover image for Withdraw and modify restriction in password django application
sium_hossain
sium_hossain

Posted on

Withdraw and modify restriction in password django application

Forcing user to make strong password always a good practice. But for making a simple web application, too much restriction in password may caused loose interest user from creating account.

Withdraw all restriction by add this line in settings.py file

AUTH_PASSWORD_VALIDATORS = []
Enter fullscreen mode Exit fullscreen mode

If we want user has to put at least 8 characters we can do that by

 AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
        'OPTIONS': {
            'min_length': 8,
        }
    },
]
Enter fullscreen mode Exit fullscreen mode

Here is all possible choice to make restricted in user password

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
        'OPTIONS': {
            'min_length': 9,
        }
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]
Enter fullscreen mode Exit fullscreen mode

Official Documentation

from django official documentation site

Top comments (1)

Collapse
 
stormytalent profile image
StormyTalent

Perfect!