Q:

Django Login bizare behavior

I'm using Django to build a web app.  I have built both the login and the registration on the home page as I'd like them to be right there, and I have a problem with the login. 
If I enter the correct credentials, it logs me in without any problem, but if I enter wrong credentials I get no error whatsoever, it just tells me that my view returned none. 
Here's my Views Code:
class MainView(View):

    def get(self, request, *args, **kwargs):
        user = request.user
        return HttpResponse(
            "Welcome " + user.username + ", You are Logged in!!  you can logout <a href=/logout/>here</a>")

class HomeView(View):
    form_class_reg = SignUpForm
    form_class_login = AuthenticationForm
    template_name = 'main/home.html'

    def get(self, request, *args, **kwargs):
        if request.user.is_authenticated is True:
            return MainView.as_view()(self.request)
        if request.user.is_authenticated is False:
            form_reg = self.form_class_reg(prefix='SignUpForm')
            form_login = self.form_class_login(prefix='SignInForm')
            return render(request, self.template_name, {
                'form_reg': form_reg,
                'form_login': form_login, })

    def post(self, request, *args, **kwargs):
        form_reg = self.form_class_reg(request. POST, prefix='SignUpForm')
        form_login = self.form_class_login(data=request. POST, prefix='SignInForm')
        if form_reg.is_valid():
            form_reg.save()
            username = form_reg.cleaned_data.get('username')
            raw_password = form_reg.cleaned_data.get('password1')
            user = authenticate(username=username, password=raw_password)
            login(request, user)
            return redirect('/')
        if form_login.is_valid():
            username = form_login.cleaned_data.get('username')
            raw_password = form_login.cleaned_data.get('password')
            user = authenticate(username=username, password=raw_password)
            if user is not None:
                login(request, user)
                return redirect('/')

            else:
                return HttpResponse("Wrong credentials")

So if user credentials are correct it redirects me to / which is HomeView and then to MainView as it is my login page that I will build later, but if I enter wrong username/pass, it never gives me the wrong credentials return. 
It just gives me this:
The view main.views. HomeView didn't return an HttpResponse object.  It returned None instead. 

Any Idea? 

A:

If the response is None then the code isn't entering the body of the conditional if form_reg.is_valid(): and since the else case isn't handled the function returns None.  You should check form.errors to check why your form validation isn't working like you expect.