簡體   English   中英

django:管理員通知,如果超級用戶顯示

[英]django: admin notifications,display if superuser

我有一些需要幫助的問題

我正在使用django-admin-notifications在我的管理面板中顯示我的通知,我希望它在用戶是超級用戶時顯示

這是我在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)

無論用戶如何,它仍然顯示True或顯示“Working”

我被困住了,我不知道該怎么做,一點幫助將不勝感激,非常感謝。

UPDATE

試過印刷價值

print get_user_perm

它說(function user_perm at 0x00000000033384A8)

嘗試添加request

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

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

但是它說notification() takes exactly 1 argument (0 given)

嘗試添加括號:

get_user_perm()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM