I created a custom group in Django’s admin site.
In my code, I want to check if a user is in this group. How do I do that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can access the groups simply through the
groupsattribute onUser.then
user.groups.all()returns[<Group: Editor>].Alternatively, and more directly, you can check if a a user is in a group by:
Note that
groupnamecan also be the actual Django Group object.