﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
27807	Overriding username validators doesn't work as documented	johnrork	Shekhar Nath Gyanwali	"The docs say you can change the default username validator by overriding the new `username_validator` attribute on a model that subclasses `auth.User`.

https://docs.djangoproject.com/en/1.10/ref/contrib/auth/#django.contrib.auth.models.User.username_validator

In practice, it seems that this value is always overwritten by the defaults, causing difficult-to-debug form validation errors.

{{{
class CustomUser(User):
    username_validator = validate_username
    
    class Meta:
        proxy = True 

>>> from myapp.models import CustomUser
>>> CustomUser.username_validator
<function validate_username at 0x105a5eea0>
>>> CustomUser._meta.get_field(""username"").validators
[<django.contrib.auth.validators.UnicodeUsernameValidator object at 0x105a5df28>, <django
.core.validators.MaxLengthValidator object at 0x105a622b0>]
}}}

I've attached a sample project in which you can replicate the issue:
1. Log in at http://localhost:8000/admin with username `admin` and password `password123`
2. Attempt to create a new Custom User with an **apostrophe (single quote) in the username**
3. Get validation error despite both the form validator and `CustomUser.username_validator` allowing apostrophes
4. Optionally uncomment the `CustomUser.__init__` method to see expected behavior, even without a custom admin form
"	Bug	closed	contrib.auth	1.10	Normal	wontfix	validation auth login forms username	Tobias Wiese	Accepted	1	0	0	0	0	0
