title: How to make form validations in Django
body: <p>I'm trying to make form validations so that certain fields only accept certain types of inputs, such as names only accept letters and phone numbers only accept 10 numbers. I tried making a validation for the first name, as shown below:</p>
  
  <pre><code>#forms.py
  
  class StudentForm(forms.ModelForm):
  # STEP 1 FORM
      student_id = forms.CharField(max_length=128, label="Student ID")
      first_name = forms.CharField(max_length=128, label="First Name", widget=forms.TextInput(attrs={'class': 'form-control'}))
      last_name = forms.CharField(max_length=128, label="Last Name")
      ssn = USSocialSecurityNumberField(widget=forms.TextInput(attrs={'class': 'form-control'}), label="SSN", help_text="Format: xxx-xx-xxxx")
      gender = forms.ChoiceField(widget=forms.Select(attrs={'class': 'form-control'}), label="Gender", choices=GENDER_CHOICES)
      dob = forms.DateField(widget=forms.DateInput(attrs={'class': 'form-control'}), label="Date of birth", help_text="Format: yyyy-mm-dd")
      contact_number = forms.CharField(max_length=128, label="Contact number")
      address = forms.CharField(max_length=128, label="Address")
      city = forms.CharField(max_length=128, label="City")
      state = forms.ChoiceField(choices=STATE_CHOICES, initial="NJ", label="State")
      zipcode = USZipCodeField(label="Zipcode")
      country = forms.ChoiceField(choices=countries, label="Country", initial="US")
      home_phone = forms.CharField(max_length=128, label="Home phone")
      cell_phone = forms.CharField(max_length=128, label="Cell phone")
      email = forms.EmailField(widget=forms.EmailInput(attrs={'class': 'form-control'}), max_length=254, validators=[validate_email], label="Email")
      background = forms.ChoiceField(choices=BACKGROUND_CHOICES, label="Background")
      location = forms.ChoiceField(choices=LOCATION_CHOICES, initial="south_plainfield", label="Location")
      workforce = forms.ChoiceField(choices=WORKFORCE_CHOICES, initial="--", label="Workforce")
      source = forms.ChoiceField(choices=SOURCE_CHOICES, initial="individual", label="Source")
      refer_by = forms.ChoiceField(choices=REFER_BY_CHOICES, initial="no refer", label="Refer by")
      last_status = forms.ChoiceField(choices=LAST_STATUS_CHOICES, initial="followup", label="Last status")
      newsletter = forms.BooleanField(widget=forms.CheckboxInput(), label="Newsletter", required=False)
      created_by = forms.CharField(max_length=128, label="Created by")
      date = forms.DateField(widget=forms.DateInput(attrs={'class': 'form-control'}), label="Date", help_text="Format: yyyy-mm-dd")
      notes = forms.CharField(widget=forms.Textarea(attrs={'class': 'form-control'}), required=False, label="notes", help_text="less than 1000 characters")
  
      def clean(self):
          cleaned_data = self.cleaned_data
          first_name = cleaned_data.get('first_name')
  
          if first_name.isalpha == False:
              raise forms.ValidationError('Please enter a real name.')
          elif first_name[0].isupper() == False or first_name[1:].isupper() == True:
              raise forms.ValidationError('Please capitalize properly')
          else:
              cleaned_data['first_name'] = first_name
  
          return cleaned_data
  
      class Meta:
          model = Student
          fields = ('student_id', 'first_name', 'last_name', 'ssn', 'gender', 'dob', 'contact_number', 'address', 'city', 'state', 'zipcode', 'country', 'home_phone', 'cell_phone', 'email', 'background', 'location', 'workforce', 'source', 'refer_by', 'last_status', 'newsletter', 'created_by', 'date', 'notes')
  </code></pre>
  
  <p>However, when submitting the form, it completely ignores it and my DB Browser shows that a name with a number in it can be accepted. Is there something I wrote incorrectly, or do I have to change some code in other places besides the forms.py? I feel like if I can solve this one validation the other ones should be easier, but if someone can tell me the correct way of making sure that a phone number in a form is only 10 numbers, that would be great as well. Thanks.</p>