我有一些问题需要帮助
我正在使用 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”。
我被卡住了,不知道该怎么办,非常感谢您的帮助。
更新
尝试打印值。
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()需要1个参数,但是没有给出
print get_user_perm(request)
。 - danidee