由于用户身份验证,我的应用程序出现错误,我已经浪费了一些时间。我认为这有点令人困惑,但也许有人可以解释原因,在我看来这很合乎逻辑。
user.is_staff
是成员变量,而是user.is_authenticated
方法。但是is_authenticated
,仅返回 True 或 False 取决于类是User
or AnonymousUser
(请参阅http://docs.djangoproject.com/en/dev/topics/auth/)
这有什么原因吗?为什么user.is_authenticated
是方法?
提前致谢