title: Django Show selected data from database based on user input in html
body: <p>I am a newbie.
  I create restaurant system by using Django. I want to display data (table number, item, and quantity of the food) which has been inserted to database. I want to show the data based on the random id which has been generated while the customer doing the food ordering. Hence, I do not know how to do it.</p>
  
  <p>Anyone can help me please</p>
  
  <p>I have tried these codes, but it only shows the back button. I cannot retrieve the data based on the random id from database</p>
  
  <p>here is my models.py</p>
  
  <pre><code>class OrderItem(models.Model):
      Table_No = models.IntegerField(blank=False)
      Item = models.TextField()
      Qty = models.IntegerField(blank=False)
      Price = models.TextField()
      Status = models.TextField(max_length=100, null=True)
      OrderId = models.TextField(max_length=100, null=True)
  </code></pre>
  
  <p>my html file:</p>
  
  <pre><code>&lt;form action="" method="post"&gt;
      {% csrf_token %}
      &lt;!--&lt;input type="Submit" name="submit" value="See Order"/&gt;--&gt;
              {% for order in so1 %}
              &lt;table width="800"&gt;
                  &lt;tr&gt;
                      &lt;th width="800"&gt;Table Number&lt;/th&gt;
                      &lt;th width="800"&gt;Item&lt;/th&gt;
                      &lt;th width="800"&gt;Quantity&lt;/th&gt;
                      &lt;th width="800"&gt;Status&lt;/th&gt;
                      &lt;th width="800"&gt;Order Id&lt;/th&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td width="800"&gt;{{ order.Table_No }}&lt;/td&gt;
                      &lt;td width="800"&gt;{{ order.Item }}&lt;/td&gt;
                      &lt;td width="800"&gt;{{ order.Qty }}&lt;/td&gt;
                      &lt;td width="800"&gt;{{ order.Status }}&lt;/td&gt;
                      &lt;td width="800"&gt;{{ order.OrderId }}&lt;/td&gt;
                  &lt;/tr&gt;
              {% endfor %}
      &lt;input action="action" onclick="window.history.go(-1); return false;" type="button" value="Back" /&gt;
  </code></pre>
  
  <p>my view:</p>
  
  <pre><code>def see_order(request):
      if request.method == "POST":
          Table_No = request.POST.get("Table_No")
          Item = request.POST.get("Item")
          Qty = request.POST.get("Qty")
          Status = request.POST.get("Status")
          OrderId = request.POST.get("OrderId")
          track_order = request.POST.get('textfield', None)
  
          if(OrderItem.objects.get(OrderId)):
              if(OrderId==OrderId): 
                  try:
                      summary = OrderItem.objects.get(OrderId=track_order)
                      so1 = OrderItem.objects.filter(Table_No=Table_No)
                      so = OrderItem.objects.filter(Item=Item)
                      so = OrderItem.objects.filter(Qty=Qty)
                      so = OrderItem.objects.filter(Status=Status)
                      so = OrderItem.objects.filter(OrderId=OrderId)
                      html = ("&lt;H1&gt;%s&lt;/H1&gt;", summary)
                      return render(request, 'restaurants/see_order.html', {'so1': so1 , 'so': so})
                  except OrderItem.DoesNotExist:
                      return HttpResponse("no such user")
      else:
          return render(request, 'restaurants/customer_page.html')
  </code></pre>
  
  <p>I expect the result will show the table number, item, and quantity when i input the random id. But it doesn't show anything except the back button.</p>