auth.models.User.username_validator

username_validator

New in Django 1.10.

Points to a validator instance used to validate usernames. Defaults to validators.UnicodeUsernameValidator on Python 3 and validators.ASCIIUsernameValidator on Python 2.

To change the default username validator, you can subclass the User model and set this attribute to a different validator instance. For example, to use ASCII usernames on Python 3:

from django.contrib.auth.models import User
from django.contrib.auth.validators import ASCIIUsernameValidator

class CustomUser(User):
    username_validator = ASCIIUsernameValidator()

    class Meta:
        proxy = True  # If no new field is added.
doc_Django
2016-10-09 18:34:26
Comments
Leave a Comment

Please login to continue.