diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py index 23185a0ece3..57ea108eb4e 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)