Hi,
I have just been following the Django documention on forms:
And I was having an issue with validating the posted data in the view code.
I came across this Stack Overflow post :
Where the solution to my problem was to use the data Keyword argument when creating a form from the POST'd data. Looking back on the docs I noticed that this wasn't specified.
So my view function now looks like this:
def login(request):
if request.method == 'POST':
form = LoginForm(data=request.POST) #<- This is where I had to use the data kwarg
if form.is_valid():
return HttpResponseRedirect('#')
return render(request, 'scoreboard/login.html', {'form': form})
else:
return render(request, 'scoreboard/login.html', {'form': LoginForm()})
