Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django import forms
- class AccountConfigForm(forms.Form):
- #username
- username = forms.CharField(
- max_length=191,
- widget=forms.TextInput(
- attrs={'class': 'form-control'}
- )
- )
- #password
- password = forms.CharField(
- max_length=32,
- widget=forms.PasswordInput(
- attrs={'class': 'form-control'}
- )
- )
- #firstname
- first_name = forms.CharField(
- max_length=30,
- widget=forms.TextInput(attrs={'class': 'form-control'})
- )
- #lastname
- last_name = forms.CharField(
- max_length=150,
- widget=forms.TextInput(attrs={'class': 'form-control'})
- )
- #email address
- email_address = forms.EmailField(
- widget=forms.EmailInput(attrs={'class': 'form-control'}),
- help_text="We'll never share your informations with anyone else.",
- )
- def clean(self):
- cleaned_data = super(AccountConfigForm, self).clean()
- username = cleaned_data.get('username')
- password = cleaned_data.get('password')
- firstname = cleaned_data.get('firstname')
- lastname = cleaned_data.get('lastname')
- email_address = cleaned_data.get('email_address')
- if not username:
- raise forms.ValidationError('You must enter your username!')
- if not password:
- raise forms.ValidationError('You must enter your password!')
- if not firstname:
- raise forms.ValidationError('You must enter your first name!')
- if not lastname:
- raise forms.ValidationError('You must enter your last name!')
- if not email_address:
- raise forms.ValidationError('You must enter your email address!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement