title: Django search query feature like Django admin or Django rest framework
body: <p>I am trying to figure out a proper way to make a search functionality for my model fields like Django's admin or Django rest framework's search feature.</p>
  
  <p>Suppose I have this model, I would like to search through all the fields.:</p>
  
  <pre><code>class User(models.Model):
      email = models.EmailField(
          unique=True,
          max_length=254,
      )
      first_name = models.CharField(max_length=15)
      last_name = models.CharField(max_length=15)
      mobile = models.BigIntegerField(unique=True)
  </code></pre>
  
  <p>First, I tried this way:</p>
  
  <pre><code>user_list = User.objects.filter(
      Q(id__icontains=int(search_input)) |
      Q(email__icontains=search_input) |
      Q(first_name__icontains=search_input) |
      Q(last_name__icontains=search_input) |
      Q(mobile__icontains=int(search_input))
  )
  </code></pre>
  
  <p>This works fine if I am filtering with only the integer search terms. However, if I pass a string value, this breaks and it gives me an error:</p>
  
  <blockquote>
    <p>ValueError: invalid literal for int() with base 10</p>
  </blockquote>
  
  <p>So now what I came up is something like this, to catch any Value errors and exclude integer searches from the filter:</p>
  
  <pre><code>try:
      user_list = User.objects.filter(
          Q(id__icontains=int(search_input)) |
          Q(email__icontains=search_input) |
          Q(first_name__icontains=search_input) |
          Q(last_name__icontains=search_input) |
          Q(mobile__icontains=int(search_input))
      )
  except ValueError as e:
      user_list = User.objects.filter(
          Q(email__icontains=search_input) |
          Q(first_name__icontains=search_input) |
          Q(last_name__icontains=search_input) |
      )
  </code></pre>
  
  <p>I am hoping there's a better way then this. Or maybe a field look up feature that I am not aware of?</p>