django - 提交表单时会发生错误
问题描述
当我单击remmber并提交表单时,会发生错误
MultiValueDictKeyError at /seller/
'out'
Request Method: POST
Request URL: http://127.0.0.1:8000/seller/
Django Version: 2.2.7
Exception Type: MultiValueDictKeyError
Exception Value:
'out'
Exception Location: /home/krishan/.local/lib/python3.6/site-packages/django/utils/datastructures.py in __getitem__, line 80
Python Executable: /usr/bin/python3
Python Version: 3.6.8
Python Path:
['/home/krishan/Desktop/property',
'/usr/lib/python36.zip',
'/usr/lib/python3.6',
'/usr/lib/python3.6/lib-dynload',
'/home/krishan/.local/lib/python3.6/site-packages',
'/usr/local/lib/python3.6/dist-packages',
'/usr/lib/python3/dist-packages']
Server time: Tue, 26 Nov 2019 10:27:23 +0000
视图.py:
def register_seller(request):
rm = request.POST.get('remember','off')
if rm == 'on':
if request.method == 'POST':
userName = request.POST['userName']
state = request.POST['state']
city = request.POST['city']
full_address = request.POST['fulladdress']
out = request.FILES['out']
bedroom_no = request.POST['bedroom_no']
kithen_img = request.FILES['kitchen']
swimming_img = request.FILES['swimming']
phone = request.POST['phone']
email = request.POST['email']
price = request.POST['price']
floor = request.POST['floor']
squre = request.POST['squre']
garden_img = request.FILES['garden']
each = seller_detail(state=state,city=city,full_address=full_address,pro_img=out,username=userName,bedroom_no=bedroom_no,kitchen_img=kithen_img,swimming_img=swimming_img,phone=phone,email=email,price=price,floor=floor,squre=squre,gerden_img=garden_img)
each.save()
return redirect('home')
else:
return render(request,'all/seller_input.html',{'remember':'Please checkout the button'})
else:
return render(request,'all/seller_input.html')
解决方案
推荐阅读
- python - 是否有一个函数可以在 Python 中用一个符号替换多个符号?
- gatsby - Gatsby 中布局的条件渲染
- php - 为什么我不能将我的表单添加到我的 MySQL 数据库中?
- python - 如何将训练好的模型转换为函数?
- r - 无法使 sen2r 函数工作,缺少一些参数?
- javascript - 给定一个数组,编写一个返回该数组所有可能的三元组/序列的函数?JavaScript
- python - 仅支持有效的不记名身份验证 - Python - Spotify API
- ruby-on-rails - Heroku 环境变量未在 javascript 中为 React/Rails 应用程序设置
- sql - 使用 SQL 提取 XML 数据
- flutter - Flutter 从“Future”返回“Widget”
"