Tuesday, August 16, 2022

remove user from a specific group in django

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 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d36d5c76-9824-4971-94ed-a2288827b656n%40googlegroups.com.

No comments:

Post a Comment