简体   繁体   English

Django - user_passes_test auth 装饰器 - 'bool' object 不可调用

[英]Django - user_passes_test auth decorator - 'bool' object is not callable

Hi I'm trying to use the user_passes_test decorator mentioned here .嗨,我正在尝试使用这里提到的 user_passes_test 装饰器。 But I keep getting this error:但我不断收到此错误:

'bool' object is not callable

My usage:我的用法:

@user_passes_test(lambda u: u.is_active() and u.is_staff())
def fulfillment(request):
    ...

is_staff is a field of User not a method. is_staff 是 User 的字段而不是方法。 Get rid of ()摆脱 ()

another situation if you write a code like this:如果您编写这样的代码,则另一种情况:

newFile = open('pickled','w')
pickle.dump(newText, newFile)
newFile.closed()

as you see, newFile.closed() will trigger the same error, 'bool' object is not callable如您所见, newFile.closed()将触发相同的错误, 'bool' object is not callable

it's caused: newFile.closed() is a boolean value... and it's assigned to a variable or in equation or something else...这是造成的: newFile.closed()是一个 boolean 值......它被分配给一个变量或方程或其他东西......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM