Greg
Greg

Reputation: 47104

Django - user_passes_test auth decorator - 'bool' object is not callable

Hi I'm trying to use the user_passes_test decorator mentioned here. 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):
    ...

Upvotes: 1

Views: 2392

Answers (2)

ismailsunni
ismailsunni

Reputation: 1506

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

it's caused : newFile.closed() is a boolean value... and it's assigned to a variable or in equation or something else...

Upvotes: 1

JamesO
JamesO

Reputation: 25936

is_staff is a field of User not a method. Get rid of ()

Upvotes: 7

Related Questions