title: Django Search query within multiple fields in same data table
body: <p>This is my models.py file. </p>
  
  <pre><code>class CustomerInfo(models.Model):
      customer_name=models.CharField('Customer Name', max_length=50)
      customer_mobile_no = models.CharField('Mobile No', null=True, blank=True,max_length=12)
      customer_price=models.IntegerField('Customer Price')
      customer_product_warrenty = models.CharField('Product Warrenty',null=True, blank=True,max_length=10)
      customer_sell_date = models.DateTimeField('date-published', auto_now=True)
      customer_product_id=models.CharField('Product ID',max_length=150,null=True, blank=True)
      customer_product_name=models.CharField('Product Name', max_length=50)
      customer_product_quantity=models.IntegerField('Quantity',default=1)
  
  
      def __str__(self):
          return self.customer_name
  </code></pre>
  
  <p>Now I want to search in muliple fieds like as <code>customer_name, customer_mobile_no,customer_product_id</code> etc. So I created views.py file </p>
  
  <pre><code>def customerPage(request):
      customers = CustomerInfo.objects.all()
  
      if request.method =="GET":
         customerid = request.GET['customer_id']
  
         try:
             customers = CustomerInfo.objects.get(pk=customerid)
             cus_name = CustomerInfo.objects.filter(customer_name__contains=customerid)
             mobile_number = CustomerInfo.objects.filter(customer_mobile_no__contains=customerid)
  
  
  
             return render(request, 'shop/customer.html', {"cus_name": cus_name,"mobile_number": mobile_number, "customers": 'customers', "site_name": "Moon Telecom"})
         except:
             return render(request, 'shop/customer.html', {"error": "Not found any info"})
  
      return render(request, 'shop/customer.html', {'customers': customers})
  </code></pre>
  
  <p>and this is my html file </p>
  
  <pre><code>{% extends "shop/base.html" %}
  
  {% block content_area %}
  
  &lt;div class="col-lg-4"&gt;
      &lt;div class="customer_search" &gt;
          &lt;form action="{% url "shop:customerPage" %}" method="GET"&gt;
              {% csrf_token %}
              &lt;div class="form-group"&gt;
                  &lt;label for="customer_id"&gt;Id:&lt;/label&gt;
                  &lt;input type="text" class="form-control" id="customer_id" placeholder="Enter customer ID" name="customer_id"&gt;
              &lt;/div&gt;
              &lt;button type="submit" class="btn btn-default"&gt;Submit&lt;/button&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="col-lg-8 customers_info"&gt;
      {% if error %}
      &lt;div class="alert alert-danger"&gt;
          &lt;strong&gt;{{error}}&lt;/strong&gt;
      &lt;/div&gt;
      {% endif %}
  
  
  
  {% if cus_name %}
  
      {% for x in cus_name  %}
      &lt;p&gt;{{x.customer_name}}&lt;/p&gt;
      {% endfor %}
  {% else %}
  &lt;p&gt;nothing foung&lt;/p&gt;
  {% endif %}
  
  
  {% if customers %}
      &lt;table class="table"&gt;
          &lt;thead&gt;
              &lt;tr&gt;
                  &lt;th&gt;Name&lt;/th&gt;
                  &lt;th&gt;Mobile No&lt;/th&gt;
                  &lt;th&gt;Product Name&lt;/th&gt;
                  &lt;th&gt;Price&lt;/th&gt;
                  &lt;th&gt;Date&lt;/th&gt;
                  &lt;th&gt;Product ID&lt;/th&gt;
                  &lt;th&gt;Warrenty&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;a href="/shop/{{customers.id}}/customerprofile"&gt;{{customers.customer_name}}&lt;/a&gt;&lt;/td&gt;
                  &lt;td&gt;{{customers.customer_mobile_no}}&lt;/td&gt;
                  &lt;td&gt;{{customers.customer_product_name}}&lt;/td&gt;
                  &lt;td&gt;{{customers.customer_price}} TK&lt;/td&gt;
                  &lt;td&gt;{{customers.customer_sell_date}}&lt;/td&gt;
                  &lt;td&gt;{{customers.customer_product_id}}&lt;/td&gt;
                  &lt;td&gt;{% if customers.customer_product_warrenty == '' %}
                  &lt;b&gt;No Warrenty&lt;/b&gt;
                  {% else %}
                   &lt;b&gt;{{customers.customer_product_warrenty}}&lt;/b&gt; Month
                  {% endif %}
                  &lt;/td&gt;
  
              &lt;/tr&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
       {% else %}
      &lt;p&gt;nothing found&lt;/p&gt;
      {% endif %}
  
  
  &lt;/div&gt;
  
  
  
  {% endblock  %}
  </code></pre>
  
  <p>I got results If I use POST method and <code>customers = CustomerInfo.objects.get(pk=customerid)</code> When I searched one field, I have got my results but When I start multiple search query from the database. I cant get any info. I want to search multiple fields within <code>CustomerInfo</code> model. Also, I was trying others mehtod but not working.</p>