title: Flask werkzeug.exceptions.BadRequestKeyError
body: <p>I've tried several different flask apps and get the following error every time.</p>
  <blockquote>
  <p>werkzeug.exceptions.BadRequestKeyError</p>
  <p>werkzeug.exceptions.HTTPException.wrap..newcls: 400 Bad
  Request: KeyError: 'name'</p>
  </blockquote>
  <p>I can't figure out why.  It must be something with my setup because the same thing is happening in different applications.  I set up a very simple model with minimal code to demonstrate.  If I remove the <code>name</code> key I get the same error with the <code>number1</code> key.  And I can't find anything on what this error even means.</p>
  <p>app.py</p>
  <pre><code>from flask import Flask
  from flask_sqlalchemy import SQLAlchemy
  
  app = Flask(__name__)
  app.config['DEBUG'] = True
  app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///flow.sqlite3'
  
  db = SQLAlchemy(app)
  
  from routes import *
  
  if __name__ == '__main__':
      # db.drop_all()
      db.create_all()
      app.run()
  </code></pre>
  <p>routes.py</p>
  <pre><code>from flask import render_template, request
  from app import app, db
  from models import Info
  
  @app.route('/', methods=['GET', 'POST'])
  def index():
      data = Info(request.form['name'], request.form['number1'], request.form['number2'])
      db.session.add(data)
      db.session.commit()
      return render_template('index.html', data=data)
  </code></pre>
  <p>models.py</p>
  <pre><code>from app import db
  
  class Info(db.Model):
      id = db.Column(db.Integer, primary_key=True)
      name = db.Column(db.String(80))
      number1 = db.Column(db.Integer)
      number2 = db.Column(db.Integer)
  
      def __init__(self, name, number1, number2):
          self.name = name
          self.number1 = number1
          self.number2 = number2
  </code></pre>
  <p>index.html</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;
    &lt;head&gt;
      &lt;meta charset=&quot;utf-8&quot;&gt;
      &lt;title&gt;&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;form id='basic' action=&quot;index.html&quot; method=&quot;post&quot;&gt;
        &lt;label for=&quot;name&quot;&gt;Name:&lt;/label&gt;
        &lt;input type=&quot;text&quot; name=&quot;name&quot; placeholder=&quot;Name&quot;&gt;
        &lt;label for=&quot;number1&quot;&gt;Number 1:&lt;/label&gt;
        &lt;input type=&quot;number&quot; name=&quot;number1&quot;&gt;
        &lt;label for=&quot;number2&quot;&gt;Number 2:&lt;/label&gt;
        &lt;input type=&quot;number&quot; name=&quot;number2&quot;&gt;
        &lt;button id='btn_submit' type=&quot;submit&quot; name=&quot;button&quot;&gt;Submit&lt;/button&gt;
      &lt;/form&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>