Django LoginView redirecting to accounts/profile instead of success_url

I have two user types usertype a and user type b i am trying to create a two seperate login forms and views using AuthenticationForm and Loginview i am getting redirected to accounts/profile after logging in

forms.py

class myForm(AuthenticationForm):

    def clean(self):
        username = self.cleaned_data.get('username')
        password = self.cleaned_data.get('password')

        if username is not None and password:
            user = authenticate(self.request, username=username, password=password)
            if user is None:
                raise self.get_invalid_login_error()
            else:
                if user is not None:
                    if user.usertype_a:
                        login(self.request,user)
        return self.cleaned_data

views.py

class MyLoginView(LoginView):
    template_name = 'log.html'
    form_class = myForm
    success_url = reverse_lazy("home")
      
Back to Top