我遇到了一些问题,需要一些帮助
我正在使用 django-admin-notifications在我的管理面板中显示我的通知,我希望它在用户是 super 用户时显示
这是我在 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”
我被卡住了,我不知道该怎么做,非常感谢您的帮助,非常感谢。
更新
尝试打印值
print get_user_perm
它说 (function user_perm at 0x00000000033384A8)
尝试添加请求
:
def notification(request):
if get_user_perm(request):
return "Working"
else:
return "Still working"
admin_notifications.register(notification)
但它说 notification() 恰好接受 1 个参数(给定 0)
最佳答案
尝试添加括号:
get_user_perm()
关于python - django:管理员通知,如果是 super 用户则显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35831667/