Advertisement
Darkolius

Untitled

Dec 5th, 2020
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. from django.utils.translation import gettext_lazy as _
  2.  
  3. from django.contrib.auth.models import User
  4. from django.contrib.auth.validators import UnicodeUsernameValidator
  5.  
  6.  
  7. class MyUnicodeUsernameValidator(UnicodeUsernameValidator):
  8.     regex = r'^[\w.@+-\s]+\Z'
  9.     message = _(
  10.         'Enter a valid username. This value may contain only letters, '
  11.         'numbers, and @/./+/-/_ characters.'
  12.     )
  13.     flags = 0
  14.  
  15.  
  16. class User2(User):
  17.     username_validator = MyUnicodeUsernameValidator()
  18.     print(User.username_validator)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement