【发布时间】:2020-10-25 05:41:48
【问题描述】:
我尝试了很多但找不到解决方案 我也尝试了javascript,但找不到解决方案
def postPage(request, id):
post = Post.objects.get(pk=id)
showcomment = Comment.objects.filter(postby = id)
form = commentForm()
form = commentForm(request.POST)
form.instance.postby = post
if form.is_valid():
form.save()
form = commentForm()
redirect('postpage', id=post.sno)
context = {'post':post, 'form':form, 'showcomment':showcomment}
return render(request, 'blog/postpage.html', context)
form = commentForm() 只有字段显示空白但数据是 刷新时提交
HTML 文件
form action="." method="POST">
{{form}}
{% csrf_token %}
<input type="submit">
</form>
【问题讨论】:
-
函数似乎没有正确缩进。此外,我并不完全清楚你的目标是什么。
-
您能否详细说明您正在尝试什么以及出了什么问题
-
当用户点击提交按钮然后清除表单域
-
提交表单后表单域不为空
-
@WillemVanOnsem 谢谢人
标签: javascript django django-forms django-templates django-formtools