title: Select data from drop-down list and save it to database in Django
body: <p>I am a newbie in Django. I want to show the food_status in drop-down list options, therefore the chef can select one of them, change it, and update it into database. It can be updated into database, but i am not sure how to display the drop-down list on template based on the food_status that I have in models.py. </p>
  
  <p>Anyone know how to do it?</p>
  
  <p>models.py </p>
  
  <pre><code>class OrderItem(models.Model):
      Table_No = models.IntegerField(blank=False)
      FoodId = models.TextField()
      Item = models.TextField()
      Qty = models.DecimalField(max_digits=5, decimal_places=0)
      Price = models.DecimalField(max_digits=10, decimal_places=2)
      TotalPrice = models.TextField()
      Note = models.TextField(max_length=100, null=True)
      OrderId = models.TextField(max_length=5, null=True)
  
      FoodStatus = (
          ('1', 'Has been ordered'),
          ('2', 'cooked'),
          ('3', 'ready to be served'),
          ('4', 'done'),
      )
      food_status = models.CharField(max_length=50, choices=FoodStatus)
  </code></pre>
  
  <p>views.py </p>
  
  <pre><code>def see_order(request):
  if request.method == "POST":
      OrderId = request.POST.get("OrderId")                           
      customerOrder = OrderItem(OrderId=OrderId)  
      so = OrderItem.objects.filter(OrderId=OrderId)  
      return render(request, 'restaurants/see_order.html', {'so': so}) 
  else:
      return render(request, 'restaurants/customer_page.html')  
  </code></pre>
  
  <p>see_order.html</p>
  
  <pre><code>&lt;form action="#" method="post"&gt;
  &lt;style&gt;
  table, th, td {
      border: 1px solid black;
      table-layout: fixed ;
      height: "2000" ;
      width: "2000" ;
  }
  &lt;/style&gt;
      {% csrf_token %}                                
      {% for order in so %}                           
      &lt;table&gt;                                     
          &lt;tr&gt;
              &lt;th&gt;Table Number&lt;/th&gt;               
              &lt;th&gt;Item&lt;/th&gt;                       
              &lt;th&gt;Quantity&lt;/th&gt;                   
              &lt;th&gt;Status&lt;/th&gt;                     
              &lt;th&gt;Order Id&lt;/th&gt;                   
          &lt;/tr&gt;   
          &lt;tr&gt;
              &lt;td&gt;{{ order.Table_No }}&lt;/td&gt;       
              &lt;td&gt;{{ order.Item }}&lt;/td&gt;           
              &lt;td&gt;{{ order.Qty }}&lt;/td&gt;            
              &lt;td&gt;{{ order.food_status }}&lt;/td&gt;    
              &lt;td&gt;{{ order.OrderId }}&lt;/td&gt;        
          &lt;/tr&gt;
      {% endfor %}
      &lt;/table&gt;
  &lt;br&gt;&lt;input action="action" onclick="window.history.go(-1); return false;" type="button" value="Back"&gt;&lt;/br&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The kitchen_page template should show the drop-down list, then the chef can choose the food_status from that drop-down list, click save button, and update the database.</p>