首页 > 解决方案 > 提交表单时会发生错误

问题描述

在此处输入图像描述

当我单击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')

标签: djangoforms

解决方案


推荐阅读