Add User to Group But Not Reflected When Run "Id"

Add user to group but not reflected when run id

Did you log the "matt" account out and back in after running the sudo usermod command? Changes to the groups a user is in under unix only take affect at login time.

Adding a user to a group in django

Find the group using Group model with the name of the group, then add the user to the user_set

from django.contrib.auth.models import Group
my_group = Group.objects.get(name='my_group_name')
my_group.user_set.add(your_user)

How to change user of groups? - Django

To add a user to group,

 group = Group.objects.get(id=id)
group.user_set.add(user)

To remove ,

group.user_set.remove(user)


Related Topics



Leave a reply



Submit