嗨我試圖使用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()
是一個布爾值...它被分配給一個變量或公式或別的東西...