1👍
✅
How about this QuerySet API Field Lookups using “in”.
request.user.groups.get(name__in=['Client1' ,'Client2' , 'Client3' , 'Client4'])
0👍
Your query boils down to:
request.user.groups.get(name='Client1')
This is because the result of:
'Client1' or 'Client2' or 'Client3' or 'Client4'
Will always be 'Client1'
.
If you just want to get all the groups the current user belongs to:
user_groups = request.user.group_set.all()
If your user can only belong to one group, then use:
user_group = request.user.group
- Copying site-package into my own project for a 'local copy'
- Is it possible to show cleaned value on invalid form in django?
Source:stackexchange.com