From an operation, a user can be added to a group as follows:
from django.contrib.auth.models import Group, User
user = User.objects.get(username='nombre_de_usuario')
group = Group.objects.get(name='nombre_de_grupo')
user.groups.add(group)
From an operation, a user in a group can be deleted as follows:
from django.contrib.auth.models import Group, User
user = User.objects.get(username='nombre_de_usuario')
group = Group.objects.get(name='nombre_de_grupo')
user.groups.remove(group)
Comments
0 comments
Please sign in to leave a comment.