title: 400 error, in Flask application while loading a route with forms and database
body: <p>I am new to flask, and I am trying to add my forms objects so I can record them in my Database.</p>
  <p>The problem is when I try to do something at the routes.py file I get a 400 error, and for the life of me I cant understand what is happening.</p>
  <p>I also want to check if the record has already been added to the database before I commit the changes to the database.</p>
  <p>Things are working ok at the database level as I have checked and created tables and headers in my models.py file, the forms.py file is also working fine, the problem occurs whenever I try to make it work at the routes.py file.</p>
  <p>I am using a Blueprint factory model to develop this application as well.</p>
  <p>Here is the Folders Structure</p>
  <p>This is the folder structure</p>
  <pre><code>.
  |
  |- __init__.py
  |- forms.py
  |- models.py
  |-routes.py
  |-templates
  |    |-clients-forms.html
  |- util.py
  </code></pre>
  <p><strong><strong>init</strong></strong>.py Contents:</p>
  <pre><code>    blueprint = Blueprint(
     'cml_blueprint',
      __name__,
      url_prefix='',
      template_folder='templates',
      static_folder='static'
  )
  </code></pre>
  <p>routes.py content:</p>
  <pre class="lang-py prettyprint-override"><code>from flask import jsonify, render_template, redirect, request, url_for
  from flask_login import (
      current_user,
      login_required,
      login_user,
      logout_user
  )
  
  from app import db, login_manager
  from app.cml import blueprint
  from app.cml.forms import (
     ClientsForm, 
      RegisterForm,
      ComercialForm,
      SupplierForm,
      NonConformityForm,
      TestForm
  )
  
  
  from flask import render_template, redirect, url_for, request
  from flask_login import login_required, current_user
  from app import login_manager
  from jinja2 import TemplateNotFound
  
  @blueprint.route('/clients-forms.html', methods=['GET','POST'])
  @login_required
  def clients-forms():
                 
      clients_form = ClientsForm(request.form) 
  
      id = request.form['id']
   
  
      registered_clients = Clients.query.filter_by(id=id).first()
      if registered_clients:
          return render_template( 'clients-forms.html', 
                                  msg='Already Registered',
                                  success=False,
                                  form=clients_form)
  
  
      registered_clients = ClientsForm(**request.form)
      db.session.add(registered_clients)
      db.session.commit()
  
  
      return render_template('clients-forms.html',
              form=cadastro_clientes_form )
  </code></pre>