1👍
✅
You need to always return some HttpResponse
. If form is not valid, then you have nothing in return. Method self.form_invalid
is returning such response with errors, so you should use it.
def post(self, request, *args, **kwargs):
form = UserRegisterForm(request.POST)
if form.is_valid():
...
return redirect('login')
else:
return self.form_invalid(form)
Source:stackexchange.com