if you see the link, they have given that User
object has an attribute is_staff
. I am trying to see what is the default value of is_staff
when we create a new user in unit testing. The code is fairly very simple:
def test_login_user(self):
User.objects.create_user('john', 'example@abc.edu', 'password')
print self.client.login(username='john', password='password')
print User.is_staff
if User.is_staff:
s = requests.get('http://127.0.0.1:8000/dashboard/')
else:
s = HttpResponseForbidden()
print s.status_code
Now when I try to print out print User.is_staff
, it is showing
type object 'User' has no attribute 'is_staff' in Django Application
I already know the user is not staff user so the output of User.is_staff
should be False
right? Could anyone point out where I am wrong here?