如何在Django-admin页面中实现这个操作? [英] How to achieve this manipulation in the Django-admin page?

查看:168
本文介绍了如何在Django-admin页面中实现这个操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户点击下面的图片中的用户 - 待处理:

When the user clicks on 'Users - Pending' in the picture below:

他应该被重定向到页面,过滤器的员工状态设置为否,不是默认的全部。点击否的网址是这个 http://127.0.0.1:8000/admin/auth/pending/?is_staff__exact=0

he should be redirected to the page with the filter by staff status set to 'No' and not 'All' which is the default. The url of that, which appears on clicking 'No' is this http://127.0.0.1:8000/admin/auth/pending/?is_staff__exact=0:

我需要什么改变在哪里实现这一点?

What do I need to change where to achieve this?

推荐答案

def get_queryset(self, request):

q = super(UserAdmin, self).get_queryset(request)
if request.user.is_superuser:
    return q
return q.filter(is_staff = False)

这篇关于如何在Django-admin页面中实现这个操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆