title: Flask WTForms: How to Refresh the Page after Submit
body: <p>I have a page which displays a list of reservation information. There is a sidebar where the users can use to filter particular reservations. One element is a multi-checkbox form where the user can select a number of classrooms.</p>
  
  <p>After the user submits the form, a URL is generated which includes the new filter information and is redirected to the URL.</p>
  
  <p>Form:</p>
  
  <pre><code>class MultiCheckboxForm(SelectMultipleField):
      widget = ListWidget(prefix_label=False)
      option_widget = CheckboxInput()
  
  class classroomSidebarForm(FlaskForm):
      classrooms_list = MultiCheckboxForm('Classrooms', coerce=int)
      submit = SubmitField('Submit selection')
  </code></pre>
  
  <p>Blueprint:</p>
  
  <pre><code>@resblueprint.route('/&lt;resfilter:res_filter&gt;/', defaults={'page': 1},
                      methods=['GET', 'POST'])
  @resblueprint.route('/&lt;resfilter:res_filter&gt;/&lt;int:page&gt;')
  def allreservations(res_filter, page):
      '''Display reservations'''
  
      # code to generate other template parameters
  
      # code to dynamically generate the choices: classrooms_list
  
      form = classroomSidebarForm()
      form.classrooms_list.choices = classrooms_list
  
      if request.method == 'POST':
          selected_classrooms = () 
  
          if form.classrooms_list.data is not None:
              for selected_classroom_id in form.classrooms_list.data:
                  selected_classrooms.append(
                      dict(form.classrooms_list.choices).selected_classroom_id)
  
          newconds = (res_filter.conds[0], res_filter.conds[1], selected_classrooms, 
                      res_filter.conds[3], res_filter.conds[4], res_filter.conds[5])
          res_filter.conds = newconds
          # the above updates the reservation filter
          # where conds[2] is replaced by the updated list of classrooms
  
          # then the same page should be rendered again, with the updated res_filter
          # preferably the form is not cleared
  
      return render_template('reservation/allres.html.j2',
                             res=res,
                             pagination=pagination,
                             res_filter=res_filter,
                             form=form)
  </code></pre>
  
  <p>Sidebar:</p>
  
  <pre><code>{% macro desktop_sidebar_res(endpoint, res_filter, form) %}
  &lt;div id="sidebar" class="col-md-2"&gt;
  
      # generates the other filter options
  
      &lt;form action="{{ url_for(endpoint, res_filter=res_filter.to_url()) }}" method="POST"&gt;
          {{ form.csrf_token }}
          {{ form.classrooms_list.label }} {{ form.classrooms_list }}
          {{ form.submit }}
      &lt;/form&gt;
  
      {{ caller and caller() }}
  &lt;/div&gt;
  {% endmacro %}
  </code></pre>
  
  <p>It can be confirmed that <code>url_for(endpoint, res_filter=res_filter.to_url())</code> correctly produces the current URL with the current filter information. </p>
  
  <p>The code cannot return the form data back to the blueprint function. The block after <code>if request.method == 'POST':</code> cannot be reached. So I suspect there might be something wrong with <code>action=""</code>.</p>
  
  <p>After new filter is generated. How would I reload the template?</p>
  
  <p>Tell me if any further clarification is needed.</p>