title: Python Flask how to get all records from html table in a request post
body: <p>I'm learning <code>Flask</code> and I want to do a simple invoice app, but I don't have any idea of how to return back on post all data row from a table with
  four fields <code>{code, description, price, quantity}</code> to be inserted or updated as the details to my DB table.</p>
  
  <p>This is just a code example.</p>
  
  <pre><code># app.py
  from flask import Flask, request, redirect, url_for, render_template
  from flask_wtf import FlaskForm
  from wtforms import StringField, IntegerField, DecimalField
  
  
  app = Flask(__main__)
  
  def save_invoice_det():
      # Here i'll iterate all rows got from the table
      pass
  
  
  class DetailForm(FlaskForm):
      item_code = IntegerField('Item Code')
      item_desc = StringField('Description')
      quantity = DecimalField('Qty')
      price = DecimalField('Price', places=2)
      total = DecimalField('Total', places=2)
  
  
  @app.route('/invoice', methods=['GET', 'POST'])
  def invoice(number):
      form = DetailForm()
  
      # This is just example models table
      query_det = Details_Inv.query.get(number)
  
      if request.method == 'POST':
  
          # Here i need to know how to get all row from the table
          if form.validate_on_submit():
              save_invoice_det()
          return redirect(url_for('list_invoices'))
  
      return render_template('invoice.html', details=query_det)
  
  
  if name == '__main__':
      app.run(debug=True)
  
  
  # invoice.html
  &lt;!DOCTYPE html&gt;
  &lt;html lang='en'&gt;
      &lt;head&gt;
          &lt;meta charset='UTF-8'&gt;
          &lt;title&gt;Create / Edit Invoice&lt;/title&gt;
       &lt;/head&gt;
  
      &lt;body&gt;
          &lt;form method='POST'&gt;
              &lt;table&gt;  &lt;!-- This table with is what i want to return back in a request --&gt;
                  &lt;thead&gt;
                      &lt;tr&gt;
                          &lt;th&gt;Item Code&lt;/th&gt;
                          &lt;th&gt;Item Descripction&lt;/th&gt;
                          &lt;th&gt;Quantity&lt;/th&gt;
                          &lt;th&gt;Price&lt;/th&gt;
                          &lt;th&gt;Total&lt;/th&gt;
                      &lt;/tr&gt;
                  &lt;/thead&gt;
  
                  &lt;tbody&gt;
                      {% for detail in details %}
                          &lt;tr&gt;
                              &lt;td&gt;{{ detail.item_code }}&lt;/td&gt;
                              &lt;td&gt;{{ detail.item_desc }}&lt;/td&gt;
                              &lt;td&gt;{{ detail.quantity }}&lt;/td&gt;
                              &lt;td&gt;{{ detail.price }}&lt;/td&gt;
                              &lt;td&gt;{{ detail.total }}&lt;/td&gt;
                          &lt;/tr&gt;
                      {% endfor %}
                   &lt;/tbody&gt;
              &lt;/table&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>