MultiValueDictKeyError 错误解决

论坛上,有很多的解决方法,那我猜测对于Django初学者或者说是开发初学者,变量名一定要确定统一,命名规则很多规范需要学习,并且在不同模块的变量名一致。

views.py中某个功能模块的代码:

def result(request):
    num_A=request.POST['valueA']
    num_B=request.POST['valueB']
    Result = int(num_A) + int(num_B)
    return render(request, 'result.html', context={'data': Result})

result.html中某段表单代码:

NumbA: + NumbB:

其中,POST[   ]中的变量就需要与 name=后的变量名一致。不然肯定报错如题。

你可能感兴趣的:(pycharm)