Re: get user that is member of two different group

2020-01-02 Thread sum abiut
Thanks, heaps Stephen. Exactly what I needed. On Fri, Jan 3, 2020 at 1:05 PM Stephen J. Butler wrote: > I don't think that's what the he asked for. It will return users who are > members of either test1 OR test2, but I read the question as returning > users who are members of both test1 AND tes

Re: get user that is member of two different group

2020-01-02 Thread Stephen J. Butler
I don't think that's what the he asked for. It will return users who are members of either test1 OR test2, but I read the question as returning users who are members of both test1 AND test2. I think the proper query would be: User.objects.filter(groups__name='test1').filter(groups__name='test2')

Re: get user that is member of two different group

2020-01-02 Thread sum abiut
Thanks On Thu, Jan 2, 2020 at 9:35 PM Lunga Baliwe wrote: > Hi there, > maybe you can use something like > User.objects.filter(groups__name__in=['test1', 'test2']). > Also check https://docs.djangoproject.com/en/3.0/ref/models/querysets/#in for > examples of using __in > > On Thu, Jan 2, 2020 a

Re: get user that is member of two different group

2020-01-02 Thread Lunga Baliwe
Hi there, maybe you can use something like User.objects.filter(groups__name__in=['test1', 'test2']). Also check https://docs.djangoproject.com/en/3.0/ref/models/querysets/#in for examples of using __in On Thu, Jan 2, 2020 at 6:49 AM sum abiut wrote: > Hi, > I have two separate groups, for examp

get user that is member of two different group

2020-01-01 Thread sum abiut
Hi, I have two separate groups, for example, test1, and test2. I want to get a user that is a member of group test1 and group test2. I've try User.objects.filter(groups__name='test1') to get users of group test1. not sure how to check if a user belongs to group test1 and is also belong to group t