title: Django Form Validation on Class Based View
body: <p>I have a very simple Class Based View:</p>
  
  <p>In views.py:</p>
  
  <pre><code>class IncidentEdit(UpdateView):
      model=Incident
      fields = visible_field_list
      sucess_url = '/status'
  </code></pre>
  
  <p>works fine as-is.  I have associated <code>CreateView</code>, <code>DeleteView</code>, etc. I can create edit and delete records. Now to fine-tune the project, I need to add field validation.</p>
  
  <p><strong>My question</strong>: Where do I put basic validation code when I have based the view on the <code>'model='</code> rather than <code>'form='</code>?  </p>
  
  <p>I could change everything to use form based views, but the whole idea was to keep it simple and it works, I just don't have the form validation except for basic 'Field Required' type validation that was defined in the model declaration.</p>
  
  <p>For example, 
  I need to make sure that one field equals the sum of two other fields. Like, </p>
  
  <p><code>ClassRoomTotal = NumBoys + NumGirls</code> </p>
  
  <p>and raise a <code>validation error</code> for the <code>ClassRoomTotal</code> field if the sum doesn't match the total.</p>
  
  <p>Thanks in advance.<br>
  I know it is a simple answer.  </p>
  
  <p>Suggestions like, "You can't do that, you have to use <code>form=IncidentForm</code> and define a form class." would help.</p>