[Fixed]-DJango – The view accounts.decorators.loginview didn't return an HttpResponse object. It returned None instead


Your current login view doesn’t account for invalid form data or invalid user. Drop the else and move the redirect('/') out of your if form.is_valid().

if form.is_valid():
    user = authenticate(username=request.POST['username'], password=request.POST['password'])
    if user is not None and user.is_active:
        django_login(request, user)
        if request.GET.get('next') is not None and request.GET.get('next') != '':
            return redirect(request.GET.get('next'))
return redirect('/')

Leave a comment