1👍
A wild guess: you forgot the csrf token.
Simply print the actual data sent to the form and the errors to see what’s happening !
def authorSearch(request):
if request.method=='POST':
form = AuthorForm(request.POST)
if form.is_valid():
#some processing here
return render(request,'authorSearch.html',{})
else:
# you want to check what's happening here
# something like this (from memory, might be wrong):
print request.POST
print form.errors
print form.non_field_errors
return HttpResponse('No such Author Found!')
else:
form = AuthorForm()
return render(request,'authorSearch.html',{'form':form})
Also, I’d personally recommend you to:
- use
Charles
or something similar to check the HTTP requests and responses - write tests 🙂
Source:stackexchange.com