Wednesday, August 17, 2022

Re: remove user from a specific group in django

usuario isn't a username, it's a QuerySet so I don't think:

User.objects.get(username=usuario)

... will work.

Please post the specific error you're getting including any traceback.

On August 16, 2022 3:30:46 PM CDT, "José Ángel Encinas" <auxiliar.sistemas@casasaterceros.com> wrote:
hi guys, im trying to remove user from a specific group using a function in django but can to do it, can help me someone?

this is the function
def accesstosystem(request):
    usuario = User.objects.filter(groups__name='revisión')
    user = User.objects.get(username=usuario)
    group = Group.objects.get(name='revisión')
    user.groups.remove(group)

kind regards 

No comments:

Post a Comment