Python Django post请求什么也不做
因此,我甚至不知道如何寻找发生同样事情的人 我正在django网站上工作,我的表单不会发布到我的数据库,相反,我会被重定向到包含表单中信息的URL,如下所示:Python Django post请求什么也不做,python,django,web,Python,Django,Web,因此,我甚至不知道如何寻找发生同样事情的人 我正在django网站上工作,我的表单不会发布到我的数据库,相反,我会被重定向到包含表单中信息的URL,如下所示: <form id="form"> <input type="hidden" id="compinp" name="compinp"> <input maxlength="20" onkeyup="showpost()" name="title" id="titleinput">
<form id="form">
<input type="hidden" id="compinp" name="compinp">
<input maxlength="20" onkeyup="showpost()" name="title" id="titleinput">
{{ captcha }}
</form>
def newentry(request):
if request.method == "GET" and request.user.is_authenticated():
#creating objects for the view, works fine too
return render(request, "newentry.html",
{"champlist": complist, "captcha": captcha})
elif request.method == "POST" and request.user.is_authenticated():
captcha = Captcha(request.POST)
title = request.POST.get("title", False)
compname = request.POST.get("compinp", False)
comp = Comp.objects.get(title=compname)
if captcha.is_valid() and title and compname:
newe= entry_generator(request.user, title, comp)
newe.save()
return redirect('/')
else:
return redirect('/')
else:
handle_home(request.method, request.user)
此视图尝试在同一项目中发布来自另一个应用程序的模型,如果这使它有所不同的话
我在请求检查post后的右侧添加了一个print
尝试,但没有打印任何内容
不确定我还可以提供哪些信息来帮助您,如果您需要,请询问(:您需要添加表单方法post:
<form id="form" method="post">
<input type="hidden" id="compinp" name="compinp">
<input maxlength="20" onkeyup="showpost()" name="title" id="titleinput">
{{ captcha }}
</form>
{{captcha}}
您需要添加表单方法post:
<form id="form" method="post">
<input type="hidden" id="compinp" name="compinp">
<input maxlength="20" onkeyup="showpost()" name="title" id="titleinput">
{{ captcha }}
</form>
{{captcha}}
不客气。它行得通,请接受答案,它会很好。不客气。它行得通,请接受答案,它会很好