Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django how to remove a user from a group

Tags:

Here is the code I add a user to a group

g = Group.objects.get(name='groupname') 
g.user_set.add(your_user)

When I delete a User how I remove this user from group?

like image 227
icn Avatar asked Jul 08 '12 01:07

icn


People also ask

How do I uninstall superuser?

Answer. Edit the account and remove all rights except one Permission, then the user is no longer a Super User and can be deleted.

What is groups in Django?

Django does provide groups and permissions option but this is a model or table level and not at the object level. Hence we decided on creating groups based on the objects on which we want to provide the access and the users were added to these groups as per requirement or based on the existing state of an object.


1 Answers

See documentation https://docs.djangoproject.com/en/stable/topics/auth/#methods

g.user_set.remove(your_user)
like image 130
TigorC Avatar answered Sep 28 '22 06:09

TigorC