Reputation: 15
I am new to django and have recently started working on it. I have made a django application and I am able to make the user log into it and display the group that he is a member of using:
request.user.groups.all()
Now, I want to display those groups, in which he is not a member, on a web page, upon his login, so that he can click on a link associated with that group and get himself registered. Please help.
Upvotes: 1
Views: 1558
Reputation: 1316
Similar question: Django in / not in query So it should be like this:
Group.objects.exclude(id__in=request.user.groups.all().values_list('id', flat=True))
Upvotes: 1