Disable password validation on the Django admin page


When developing with Django, you sometimes need to create a new user from the admin page. Since Django 1.9, creating a new user from the admin page goes through password validation:

  • Cannot be too similar to personal information
  • Must be at least 8 characters
  • Cannot be a common password
  • Cannot be entirely numeric

2022-12-08 23 42 27

When you need to test and iterate quickly, this is very inconvenient, so we want to disable the feature.

Using simple passwords in Django

  • settings.py
    • Comment out the entire AUTH_PASSWORD_VALIDATORS block
    • Assign an empty list
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    
    # ...
      
    '''
    AUTH_PASSWORD_VALIDATORS = [
        {
            'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
        },
        {
            'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
        },
        {
            'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
        },
        {
            'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
        },
    ]
    '''
      
    AUTH_PASSWORD_VALIDATORS = []
      
    # ...
    

Restart the project (python manage.py runserver) and you can confirm that validation is disabled.

2022-12-08 23 41 57