def monkey_patch_username_validator():
 username = User._meta.get_field('username')
 regex = re.compile(('^%s$' % get_username_re_rule()))
 for validator in username.validators:
  if isinstance(validator, RegexValidator):
   validator.regex = regex

def monkey_patch_username_validator ( ) : username = User . _meta . get_field ( 'username' ) regex = re . compile ( ( '^%s$' % get_username_re_rule ( ) ) ) for validator in username . validators : if isinstance ( validator , RegexValidator ) : validator . regex = regex
in 1 .