Django表单上传图片和文字,出现MultiValueDictKeyError错误,该怎么解决?

      <div class="col-md-6">
          <h3 style="font-family:STKaiTi;text-align:center;margin-bottom: 30px;" >人脸图截取</h3>
          <form action="" method="POST">

                 {% csrf_token %}
                <img  class="center" id="screenshot-img" src="" width="400px" height="300px"  style="margin-left: 65px">
                <input type="hidden"  id="ee" name="ee"  value="">
                <br/>
                <input class="center btn btn-warning"  type="submit" value="Analyse" style="margin-top:20px;margin-left: 225px">
                <input type="text" name="messageId111" placeholder="请输入签到的课程编号!" style="color:black;border-radius:5px;margin-left: 470px;">
          </form>
      </div>

 

 

MultiValueDictKeyError at /smessage1
'massageId111'
Request Method:    POST
Request URL:    http://127.0.0.1:8000/smessage1
Django Version:    3.2
Exception Type:    MultiValueDictKeyError
Exception Value:    
'massageId111'
Exception Location:    /home/zyx/.local/lib/python3.6/site-packages/django/utils/datastructures.py, line 78, in __getitem__
Python Executable:    /usr/bin/python3.6
Python Version:    3.6.13

debug一下你接收表单的视图函数,看看能否正常接收请求信息

您好,我是有问必答小助手,你的问题已经有小伙伴为您解答了问题,您看下是否解决了您的问题,可以追评进行沟通哦~

如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632

前后端参数名不一致 前端是 messageId111 后端取值是massageId111

是不是许多语句未导入的原因

非常感谢您使用有问必答服务,为了后续更快速的帮您解决问题,现诚邀您参与有问必答体验反馈。您的建议将会运用到我们的产品优化中,希望能得到您的支持与协助!

速戳参与调研>>>https://t.csdnimg.cn/Kf0y