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

前端 未结 9 803
遇见更好的自我
遇见更好的自我 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条回答
  •  萌比男神i
    2020-12-12 16:59

    $ python manage.py shell <<'EOF'
    > from django.contrib.auth.models import User
    > User.objects.filter(groups__name='blogger')
    > EOF
    ...
    (InteractiveConsole)
    >>> >>> [, , , '...(remaining elements truncated)...']
    

    (simplified from cms' answer, which I can't edit)

提交回复
热议问题