user.groups.clear()
This will remove the groups from the user, but does not affect the groups themselves.
user.groups.all().delete()
This removes the actual groups. You probably do not want to do this, because there may be other users belonging to these groups.
source share