title: Django: Check if user input does not exist in db and throw ValidationError
body: <p>I have an IntegerField in my form where a user can input an <code>id</code>. Before the form is submitted I want to check if that <code>id</code> actually exists and if it doesn't I want to throw the user a Validation Error if it doesn't. I've tried the following. Is there an easier way to do this?</p>
  
  <p><strong>forms.py</strong></p>
  
  <pre><code>class IncidentSearchForm(forms.Form):
      id = forms.IntegerField(label="ID",required=False)
  
      def search(self):
          id = self.cleaned_data.get('id')
          try:
              incident_id = Incident.object.filter(pk=id).exists()
          except Incident.DoesNotExist:
              raise forms.ValidationError('This does not exist.')
  
      query = Incident.objects.all()
  
      if id is not None:
          query = query.filter(id=self.cleaned_data.get('id'))
  
      return(query)
  </code></pre>