Advertisement
Guest User

Untitled

a guest
Jun 29th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.73 KB | None | 0 0
  1. from django import forms
  2.  
  3.  
  4. class AccountConfigForm(forms.Form):
  5.     #username
  6.     username = forms.CharField(
  7.         max_length=191,
  8.         widget=forms.TextInput(
  9.             attrs={'class': 'form-control'}
  10.         )
  11.     )
  12.     #password
  13.     password = forms.CharField(
  14.         max_length=32,
  15.         widget=forms.PasswordInput(
  16.             attrs={'class': 'form-control'}
  17.         )
  18.     )
  19.     #firstname
  20.     first_name = forms.CharField(
  21.         max_length=30,
  22.         widget=forms.TextInput(attrs={'class': 'form-control'})
  23.     )
  24.     #lastname
  25.     last_name = forms.CharField(
  26.         max_length=150,
  27.         widget=forms.TextInput(attrs={'class': 'form-control'})
  28.     )
  29.     #email address
  30.     email_address = forms.EmailField(
  31.         widget=forms.EmailInput(attrs={'class': 'form-control'}),
  32.         help_text="We'll never share your informations with anyone else.",
  33.     )
  34.     def clean(self):
  35.         cleaned_data = super(AccountConfigForm, self).clean()
  36.         username = cleaned_data.get('username')
  37.         password = cleaned_data.get('password')
  38.         firstname = cleaned_data.get('firstname')
  39.         lastname = cleaned_data.get('lastname')
  40.         email_address = cleaned_data.get('email_address')
  41.         if not username:
  42.             raise forms.ValidationError('You must enter your username!')
  43.         if not password:
  44.             raise forms.ValidationError('You must enter your password!')
  45.         if not firstname:
  46.             raise forms.ValidationError('You must enter your first name!')
  47.         if not lastname:
  48.             raise forms.ValidationError('You must enter your last name!')
  49.         if not email_address:
  50.             raise forms.ValidationError('You must enter your email address!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement