A
A
argonnest2020-10-16 21:32:28
WYSIWYG
argonnest, 2020-10-16 21:32:28

Why am I getting a BadRequestKeyError in Flask?

Good evening. I write a blog in Flask and use Quill.JS as a WYSIYG editor. But when I submit an article to the DB, a BadRequestKeyError occurs. Allegedly, the server does not understand what the 'post' key is. Before adding Quill.JS, everything worked flawlessly.
Here is the code:
- main.py

@app.route('/create', methods=['POST', 'GET'])
def create():
  db = get_db()
  dbase = FDataBase(db)

  if request.method == 'POST':
    if len(request.form['title']) > 4:
      res = dbase.addPost(request.form['title'], request.form['post'], request.form['url'])
      print(request.form.get('post'))
      return redirect(url_for('index'))

  return render_template('create.html')

- layout
<div class="form-control w-100" name="post" id="post" cols="30" rows="9"
                        onfocus="this.placeholder = ''" onblur="this.placeholder = 'Начинайте творить'"
                        placeholder='Начинайте творить' required></div>
                        <script>
                          var quill = new Quill('#post', {
                            theme: 'snow'
                          });
                        </script>
                    </div>

I learned how to do the whole backend from selfedu, the 10th video was the last one.
Here is the entire error code:
5f89e7057c426099212570.png
If you need more information, write, I'll throw everything off
Please don't rush, I'm a beginner, and I don't understand much yet.
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2020-10-17
@dimonchik2013

write, I'll drop everything

money on the card too?
for camel - style - slit
learn debugging, at least with prints - display what you get from the browser and look for your post there,
rename post to post1 just in case

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question