From dbcade4146c301eea00a91c8be9730e057b4eba7 Mon Sep 17 00:00:00 2001 From: Raynaldo Rivera Date: Mon, 13 Oct 2014 11:12:27 -0700 Subject: [PATCH] Prevent space from being in username during registration --- registration/forms.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/registration/forms.py b/registration/forms.py index 79e893c3..320b4ac4 100644 --- a/registration/forms.py +++ b/registration/forms.py @@ -9,6 +9,9 @@ class RegistrationForm(forms.Form): email_again = forms.CharField(max_length=254, required=True, label="Email Again") def clean(self): + if ' ' in self.cleaned_data['username']: + raise forms.ValidationError(u'Username can not contain a space') + if 'password' in self.cleaned_data and 'password_again' in self.cleaned_data: if self.cleaned_data['password'] != self.cleaned_data['password_again']: raise forms.ValidationError(u'Passwords do not match')