django: request.user is an int, not a User object
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 do开发者_开发技巧es 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?
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
精彩评论