问题描述
|
嗨,我正在尝试使用此处提到的user_passes_test装饰器。但我不断收到此错误:
\'bool\' object is not callable
我的用法:
@user_passes_test(lambda u: u.is_active() and u.is_staff())
def fulfillment(request):
...
解决方法
is_staff是用户字段而不是方法。摆脱 ()
,另一种情况,如果您编写这样的代码:
newFile = open(\'pickled\',\'w\')
pickle.dump(newText,newFile)
newFile.closed()
如您所见,“ 3”会触发相同的错误,“ 4”
原因:ѭ3是布尔值...并且已分配给变量,方程式或其他内容...