How to get a list of all users with a specific permission group in Django

前端 未结 9 805
遇见更好的自我
遇见更好的自我 2020-12-12 16:13

I want to get a list of all Django auth user with a specific permission group, something like this:

user_dict = {
    \'queryset\': User.objects.filter(permi         


        
9条回答
  •  无人及你
    2020-12-12 16:50

    Groups are many-to-many with Users (you see, nothing unusual, just Django models...), so the answer by cms is right. Plus this works both ways: having a group, you can list all users in it by inspecting user_set attribute.

提交回复
热议问题