TypeError:'bool' object is not callable 和 has no module named flask.ext的问题

       这两天在跟着教程使用flask搭建网站,途中遇到一些错误,一个是flask.ext.wtf的,其中.ext是一种过渡,在其他人代码运行好像没错,我就一直提示找不到flask.ext,于是我直接改为flask_wtf和flask_xxxx,就可以了。

        之后又遇到“TypeError:'bool' object is not callable”的错误,提示错误代码行如下:

if g.user is not None and g.user.is_authenticated()

        根源在:

    @property
    def is_authenticated(self):
        return True

    @property
    def is_active(self):
        return True

    @property
    def is_anonymous(self):
        return False

          于是把函数改为变量,再把调用函数的地方括号去掉,如下:

    is_authenticated = True
    is_active = True
    is_anonymous = True

猜你喜欢

转载自blog.csdn.net/weixin_39220714/article/details/80287633