嗨我试图使用user_passes_test修饰符mentioned here。不过,我不断收到此错误:Django - user_passes_test auth装饰器 - 'bool'对象不可调用
'bool' object is not callable
我的用法:
@user_passes_test(lambda u: u.is_active() and u.is_staff())
def fulfillment(request):
...
嗨我试图使用user_passes_test修饰符mentioned here。不过,我不断收到此错误:Django - user_passes_test auth装饰器 - 'bool'对象不可调用
'bool' object is not callable
我的用法:
@user_passes_test(lambda u: u.is_active() and u.is_staff())
def fulfillment(request):
...
is_staff是用户的field不是方法。摆脱()
另一种情况,如果你写这样的代码:
newFile = open('pickled','w')
pickle.dump(newText, newFile)
newFile.closed()
正如你看到的,newFile.closed()
会引发同样的错误,'bool' object is not callable
它造成的:newFile.closed()
是一个布尔值...它被分配给一个变量或公式或别的东西...