redirect after access

Hi, in the login related view, I would like the user, depending on the group they belong to be redirected to a specific page
I wrote this code but it doesn’t work, it doesn’t recognize either the admin or responsible group. I checked in the admin page and the 2 users have the group referenced. I post the class I use

def AccessView(request):
    if request.method == 'POST':
        form = AuthenticationForm(data=request.POST).
        if form.is_valid():
            # login(request, form.get_user()) # Retrieve UserName
            userName = request.POST.get('username')
            passWord = request.POST.get('password')
            user = authenticate(request, username=form.get_user(), password=passWord)
            if user is not None:
                login(request, form.get_user())
                # Gets the user's groups
                groups = user.groups.all()
                # Based on the Group retrieves the Page
                print('gruAP ', user, groups)
                if Group.objects.filter(name='Administrator') in groups:
                    print('1')
                    # Redirect to administrator page.
                    return redirect('/BO')                
                elif Group.objects.filter(name='Responsible') in groups:
                    print('2')
                    # Redirect to the staff page.
                    return redirect('/BO')
                else:
                    # We redirect to the default page.
                    print('3')
                    return redirect('/')
            else:
                # Invalid credentials, handle accordingly
                print('NO GIUST')
                # return(request, '', {'form': form})
    else:
        form = AuthenticationForm()
        return(request, 'Users/Access.html', {'form': form})

This query returns a queryset and not the instance of group. This queryset is not going to be in the other queryset. You probably want to use get here instead of filter.

It’s working now, I didn’t think in the right way
Thank you