title: Flask is returning TypeError: The view function did not return a valid response
body: <p>I am new to Flask and trying to build simple userform page using flask and running into error. When I am trying to render just pure HTML, extending base.html, everything works perfectly, however when added macro, result is below. I tried everything and cannot solve the issue on my own. Any hints, what am I doing wrong? </p>
  
  <pre><code>[2019-07-09 22:19:39,837] ERROR in app: Exception on / [GET]
  Traceback (most recent call last):
    File "path/venv/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app
      response = self.full_dispatch_request()
    File "path/venv/lib/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request
      return self.finalize_request(rv)
    File "path/venv/lib/python3.6/site-packages/flask/app.py", line 1967, in finalize_request
      response = self.make_response(rv)
    File "path/venv/lib/python3.6/site-packages/flask/app.py", line 2130, in make_response
      " {rv.__class__.__name__}.".format(rv=rv)
  TypeError: The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a UserForm.
  127.0.0.1 - - [09/Jul/2019 22:19:39] "GET / HTTP/1.1" 500 -
  </code></pre>
  
  <p>This is my Python code:</p>
  
  <pre><code>from app import app
  from flask import render_template
  from flask_wtf import FlaskForm
  from wtforms import StringField, TextAreaField, SelectField
  from wtforms.validators import InputRequired
  
  
  @app.route('/', methods=['GET', 'POST'])
  
  class UserForm(FlaskForm):
      prefix = StringField("Prefix", validators=[InputRequired()])
      anrede = StringField("Anrede", validators=[InputRequired()])
  
  def form():
      form = UserForm()
      return render_template('html_one_flask.html', form=form)
  </code></pre>
  
  <p>form which I am trying to load</p>
  
  <pre><code>{% extends "base.html" %}
  
  {% from "render_field.html" import render_field %}
  {% block content %}
  
  &lt;div class = "container"&gt;
      &lt;div class = "spacer" &gt; &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class = "container" id = "data_category"&gt;PERSONAL DATEN&lt;/div&gt;
  &lt;div class = "container"&gt;
      &lt;div class = "spacer" &gt; &lt;/div&gt;
          &lt;div class="form-group row flex-v-center" id = 1&gt;
              {{ render_field(form.prefix), placeholder = form.prefix.label.text }}
              {{ render_field(form.anrede), placeholder = form.anrede.label.text }}
          &lt;/div&gt;
  &lt;/div&gt;
  {% endblock %}
  </code></pre>
  
  <p>and macro imported from another file</p>
  
  <pre><code>{% macro render_field(field) %}
  
  &lt;div class = "col-0.75"&gt;
      &lt;div class = "spacer_label" &gt; &lt;/div&gt;
      &lt;label for="{{ field.name }}"&gt;{{ field.label.text }} &lt;/label&gt;
  &lt;/div&gt;
  &lt;div class = "col-1"&gt;
      {{ field(class_ = "form-control input-sm", **kwargs|safe }}
  &lt;/div&gt;
  
  {% endmacro %}
  </code></pre>