我想通过html模板将数据发布到数据库中,并将渲染模板成功插入到您的数据库。但是显示错误
TypeError at /empdetails
'QueryDict' object is not callable
这是我的密码模型.py
^{pr2}$以及视图.py
def Empdetails(request):
num=request.POST('eno')
nam=request.POST('ename')
add=request.POST('eadd')
details=Employee(eno=num,ename=nam,eadd=add)
details.save()
return render(request,'emp.html')
和模板emp.html
<!DOCTYPE html>
{% load static %}
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form action="/templates/inserted.html" method="post">
<label for="eno">Eid :</label>
<input type="text" name=" " value="" placeholder="eid" id="eno">
<label for="nam">Ename</label>
<input type="text" name=" " value="" placeholder="name" id="nam">
<label for="add">Eadd</label>
<input type="text" name=" " value="" placeholder="add" id="add">
<input type="submit" value="submit">
</form>
</body>
</html>
尝试打印/记录您的}的POST变量。在
request.POST
对象的内容-是否使用您认为发送它们的名称发送数据?您的表单包含名称为ex.reddy
、name
和add
的字段,但是您的视图正在查找名称为eno
、ename
和{.get
的默认行为是在提供的键不在对象中时返回None
,因此如果您实际上没有发送eno
键,那么{也就是说,当您试图用
null=True
将一个空值保存到一个字段时,会得到一个IntegrityError
。你是否有未申请的移民?在编辑:对编辑进行寻址,
querydict is not callable
意味着你试图像函数一样使用字典。request.POST('thing')
无法工作-它应该是request.POST['thing']
或以前的.get语法。在编辑:在处理其他编辑时,HTML表单字段的名称现在全部为空。{cds>你应该把这些字段的值发送到cds}。在
相关问题 更多 >
编程相关推荐