简体   繁体   English

django:管理员通知,如果超级用户显示

[英]django: admin notifications,display if superuser

I am having a bit of a problems that would like some help with 我有一些需要帮助的问题

I am using django-admin-notifications to display my notifications in my admin panel and I would like it to display when the user is a super user 我正在使用django-admin-notifications在我的管理面板中显示我的通知,我希望它在用户是超级用户时显示

Here is my code in admin.py: 这是我在admin.py中的代码:

def get_user_perm(request): 
    if not request.user.is_superuser:
        return True
    else:
        return False

def notification():
    if get_user_perm:

        return "Working"
    else:
        return "Still working"
admin_notifications.register(notification)

It still says True or displays "Working" regardless of the user 无论用户如何,它仍然显示True或显示“Working”

I am stuck and I don't know what to do, a bit of help will be appreciated, many thanks. 我被困住了,我不知道该怎么做,一点帮助将不胜感激,非常感谢。

UPDATE UPDATE

Tried printing the value 试过印刷价值

print get_user_perm

it says (function user_perm at 0x00000000033384A8) 它说(function user_perm at 0x00000000033384A8)

Tried adding the request : 尝试添加request

def notification(request):
    if get_user_perm(request):

        return "Working"
    else:
        return "Still working"
admin_notifications.register(notification)

but it says notification() takes exactly 1 argument (0 given) 但是它说notification() takes exactly 1 argument (0 given)

尝试添加括号:

get_user_perm()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM