Private
Public Access
1
0

forcing first name to have at least one character in user form

This commit is contained in:
Sander Roosendaal
2017-12-08 11:11:16 +01:00
parent be596dd060
commit ce8d30dba6

View File

@@ -987,6 +987,14 @@ class UserForm(ModelForm):
model = User
fields = ['first_name','last_name','email']
def clean_first_name(self):
first_name = self.cleaned_data.get('first_name')
if len(first_name):
return first_name
raise forms.ValidationError('Please fill in your first name')
def clean_email(self):
email = self.cleaned_data.get('email')