Commits

ubernostrum  committed 339f503

Change username field in RegistrationForm to a RegexField

  • Participants
  • Parent commits e263c55

Comments (0)

Files changed (1)

File registration/forms.py

     ``RegistrationProfile.objects.create_inactive_user()``.
     
     """
-    username = forms.CharField(max_length=30,
-                               widget=forms.TextInput(attrs=attrs_dict),
-                               label=_(u'username'))
+    username = forms.RegexField(regex=r'^\w+$',
+                                max_length=30,
+                                widget=forms.TextInput(attrs=attrs_dict),
+                                label=_(u'username'))
     email = forms.EmailField(widget=forms.TextInput(attrs=dict(attrs_dict,
                                                                maxlength=75)),
                              label=_(u'email address'))
         in use.
         
         """
-        if not alnum_re.search(self.cleaned_data['username']):
-            raise forms.ValidationError(_(u'Usernames can only contain letters, numbers and underscores'))
         try:
             user = User.objects.get(username__iexact=self.cleaned_data['username'])
         except User.DoesNotExist: