mirror of
https://github.com/django/django.git
synced 2025-03-31 19:46:42 +00:00
Explained why UserCreationForm performs custom validation of usernames. Refs #13147.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17225 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
a4e516b593
commit
c7534584e8
@ -69,6 +69,8 @@ class UserCreationForm(forms.ModelForm):
|
|||||||
fields = ("username",)
|
fields = ("username",)
|
||||||
|
|
||||||
def clean_username(self):
|
def clean_username(self):
|
||||||
|
# Since User.username is unique, this check is redundant,
|
||||||
|
# but it sets a nicer error message than the ORM. See #13147.
|
||||||
username = self.cleaned_data["username"]
|
username = self.cleaned_data["username"]
|
||||||
try:
|
try:
|
||||||
User.objects.get(username=username)
|
User.objects.get(username=username)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user