From c7534584e8cbb33203675f92e71ec76fb5afd95c Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Sat, 17 Dec 2011 15:30:55 +0000 Subject: [PATCH] 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 --- django/contrib/auth/forms.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py index 23185a0ece..57ea108eb4 100644 --- a/django/contrib/auth/forms.py +++ b/django/contrib/auth/forms.py @@ -69,6 +69,8 @@ class UserCreationForm(forms.ModelForm): fields = ("username",) 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"] try: User.objects.get(username=username)