我在 Django 中创建了一个表单,如下所示:
class advancedsearch(forms.Form):
choices = forms.ChoiceField (label="choices", choices = ("1", "2", "3"), required= False)
现在我试图在如下视图中使用它:
def advancedsearch(request):
# if request.method == "POST":
# search = advancedsearch(request.POST, request.FILES)
# if search.is_valid():
# return HttpResponseRedirect(reverse("view.designs")) # UPDATE REDIRECT
# else:
# print "FORM IS NOT VALID"
# # GET request
# else:
# search = advancedsearch()
# return render_to_response("advancedsearch.html", {
# "search": search,
# }, context_instance=RequestContext(request,{}))
# # generic case
search = advancedsearch()
return render_to_response("advancedsearch.html", {
"search": search,
}, context_instance=RequestContext(request, {}))
我得到的错误是advancedsearch() takes exactly 1 argument (0 given)
我不认为我需要将参数传递给函数 - 但看起来我这样做了......我应该传递什么?