tags:

views:

44

answers:

1

I'm using django 1.0 and have a method in views.py that starts out like this:

def my_view(request, org_id):
    a = request.user.is_staff() #this line has error
    #more code...

When I try to load the page, I receive the error "'int' object is not callable" on the line marked above. My models.py file does contain a "User" object which is imported at the top of views.py, but removing this import statement from views.py does not seem to prevent this error. Is it possible that this other User class is causing a conflict in another one of my files, perhaps? Do you have any other ideas regarding what could possibly be causing this error?

+2  A: 

I guess the problem is is_staff(). Try

a = request.user.is_staff

is_staff is a field of the model. But it is boolean. Nevertheless it could be that it is stored as int internally.

User model documentation

Felix Kling
+1 - and, in case anyone is wondering why a field called `is_staff` would be an integer, it's actually defined as a boolean but certain database backends return ints for boolean fields. Makes no difference in Python anyway.
Daniel Roseman
@Daniel Roseman: Yes, that is exactly what I thought.
Felix Kling
Thanks, Felix! I can't believe I missed that!
Matt Boehm
Very often the small and simple things are those that make you crazy ;)
Felix Kling