Commits

Brodie Rao committed 5a7aec9

Don't let MultipleObjectsReturned get raised during registration

Given two users "bob" and "Bob", attempting to register as any form of
"bob" would raise MultipleObjectsReturned instead of telling the user
the name's taken.

  • Participants
  • Parent commits d36a382

Comments (0)

Files changed (1)

File registration/forms.py

         in use.
         
         """
-        try:
-            user = User.objects.get(username__iexact=self.cleaned_data['username'])
-        except User.DoesNotExist:
-            return self.cleaned_data['username']
-        raise forms.ValidationError(_("A user with that username already exists."))
+        if User.objects.filter(username__iexact=self.cleaned_data['username']):
+            raise forms.ValidationError(_("A user with that username already exists."))
+        return self.cleaned_data['username']
 
     def clean(self):
         """