我试图添加使用django &'POST'方法提交的学生的详细信息。 提交时,我将详细信息保存在我的'py'文件中。之后,我想重定向到主页。 早些时候我用在django中提交表单后重定向到带有参数的主页
return render_to_response("home.html",{ "edit":0,"msg":'saved'}, context_instance=RequestContext(request))
但在主页的每个耳目一新,它将插入数据表。 然后我尝试使用“HttpResponseRedirect”,但它不支持参数传递。 我该如何解决这个问题?
add.py
stud = student(name=request.POST['studname'])
stud.save()
return render_to_response("home.html",{ "edit":0,"msg":'saved'}, context_instance=RequestContext(request))
student.html
<form id = "addForm" name = "addForm" action = "" method = 'POST' >
<table>
<tr>
<td>Name.</td>
<td><input type="text" name="studname" id="studname"></td>
</tr>
</table>
</form>
化妆名同一主题的另一篇文章作为unigue在Django模型 – 2014-10-10 09:05:53
=真当你得到你的答案时,将其标记为已验证。 – ancho 2014-10-10 11:08:53
但是不同学生的名字,班级等可以相同 – user123 2014-10-11 04:54:20