django MultiValueDictKeyError error, how do I deal with it

前端 未结 7 2054
终归单人心
终归单人心 2020-11-22 11:14

I\'m trying to save a object to my database, but it\'s throwing a MultiValueDictKeyError error.

The problems lies within the form, the is_private<

相关标签:
7条回答
  • 2020-11-22 12:05

    Another thing to remember is that request.POST['keyword'] refers to the element identified by the specified html name attribute keyword.

    So, if your form is:

    <form action="/login/" method="POST">
      <input type="text" name="keyword" placeholder="Search query">
      <input type="number" name="results" placeholder="Number of results">
    </form>
    

    then, request.POST['keyword'] and request.POST['results'] will contain the value of the input elements keyword and results, respectively.

    0 讨论(0)
提交回复
热议问题