title: Page with a dynamic number of forms, each form for each table row
body: <p>The company has workers performing various activities during a day. Each activity has <code>start_time</code> and <code>finish_time</code>. It is usual that workers forget to beep the end of activity (<code>finish_time</code>) and that's because there is a stored procedure <code>read_unended time_from time_to</code> which reads records between <code>time_from</code> and <code>time_to</code> which has not <code>finish_time</code> (is <code>NULL</code>).
  For example</p>
  <pre><code>id  name    day         start_time              finish_time place   activity
  38  Thomas  2021-12-03  2021-12-03 08:51:38.000 NULL    p1  a1
  28  Charles 2021-12-02  2021-12-02 12:29:03.000 NULL    p2  a2
  49  John    2021-12-06  2021-12-06 11:59:48.000 NULL    p3  a3
  68  Jessie  2021-12-08  2021-12-08 10:55:12.000 NULL    p4  a4
  82  Susanne 2021-12-10  2021-12-10 12:38:03.000 NULL    p5  a5
  </code></pre>
  <p>There is a form in (<code>forms.py</code>)</p>
  <pre><code>class FromToForm(Form):
      start_date = DateField(widget=AdminDateWidget())
      start_time = TimeField(widget=AdminTimeWidget())
      end_date = DateField(widget=AdminDateWidget())
      end_time = TimeField(widget=AdminTimeWidget())
  </code></pre>
  <p>There is a view in (<code>views.py</code>) which displays such a table.</p>
  <pre><code>def ending(req):
      from_to_form = FromToForm()
      result = []
      context = {
                  'form': from_to_form,
                  'result': result
                }
      if req.method == &quot;POST&quot;:
          from_to_form = FromToForm(req.POST)
          if from_to_form.is_valid():
              start = datetime.combine(from_to_form.cleaned_data['start_date'], from_to_form.cleaned_data['start_time']).isoformat()
              end = datetime.combine(from_to_form.cleaned_data['end_date'], from_to_form.cleaned_data['end_time']).isoformat()
              with connections[&quot;mssql_database&quot;].cursor() as cursor:
                  cursor.execute(&quot;EXEC read_unended @dt_od='%s', @dt_do='%s'&quot; % (start, end))
                  result = cursor.fetchall()
              context['result'] = result
              return render(req, 'ending.html', context)
          else:
              return render(req, 'ending.html', context)
      else:
          return render(req, 'ending.html', context)
  </code></pre>
  <p>and an associated template in <code>templates.py</code>.</p>
  <pre><code>&lt;form action='.' method='POST'&gt;{% csrf_token %}
                  {{ form.media }}
                  {{ form.as_p }}
                  &lt;input type='submit' value='Read unended' class=&quot;btn btn-secondary&quot; /&gt;
          &lt;/form&gt;
  {% if result %}
          &lt;table class=&quot;table mb-0&quot;&gt;
                  &lt;thead&gt;
                          &lt;tr&gt;
                                  &lt;th&gt;id&lt;/th&gt;
                                  &lt;th&gt;name&lt;/th&gt;
                                  &lt;th&gt;day&lt;/th&gt;
                                  &lt;th&gt;start_time&lt;/th&gt;
                                  &lt;th&gt;finish_time&lt;/th&gt;
                                  &lt;th&gt;place&lt;/th&gt;
                                  &lt;th&gt;activity&lt;/th&gt;
                          &lt;/tr&gt;
                  &lt;/thead&gt;
                  &lt;tbody&gt;
                     {%for i in result %}
                       &lt;tr&gt;
                             &lt;td&gt;{{i.0}}&lt;/td&gt;
                             &lt;td&gt;{{i.1}}&lt;/td&gt;
                             &lt;td&gt;{{i.2}}&lt;/td&gt;
                             &lt;td&gt;{{i.3}}&lt;/td&gt;
                             &lt;td&gt;CELL TO INSERT END TIME*&lt;/td&gt;
                             &lt;td&gt;{{i.5}}&lt;/td&gt;
                             &lt;td&gt;{{i.6}}&lt;/td&gt;
                             &lt;td&gt;BUTTON TO FINISH THIS ACTIVITY**&lt;td/&gt;
                       &lt;/tr&gt;
                     {% endfor %}
                  &lt;/tbody&gt;
          &lt;/table&gt;
          {% else %}
             Every activity is ended
          {% endif %}
  </code></pre>
  <p>** and * is not implemented yet.
  I'd like to implement the following functionality. In every row of the dynamically generated table, there should be a button ** to finish this activity (this row) with the time * the user of the application inserts. In that moment the page should refresh and that row should not be displayed anymore, because this activity has already <code>finish_time</code> assigned. How can I implement such a view and template? Do I need to add a dynamically generated fields to the existing form? What do you suggest?</p>