简体   繁体   English

AttributeError: 'Flask' object 没有属性 'login_manager'

[英]AttributeError: 'Flask' object has no attribute 'login_manager'

I'm working on a flask project where I log in a page by filling a login form.我正在处理 flask 项目,我通过填写登录表单登录页面。 However when I try to logout from the page I get AttributeError: 'Flask' object has no attribute 'login_manager' .但是,当我尝试从页面注销时,我得到AttributeError: 'Flask' object has no attribute 'login_manager' After searching the flask documentation I saw how the login_manager module is used but the login form endpoint in the flask documentation was different from the one I created, so modifying my code seems the best solution.在搜索 flask 文档后,我看到了 login_manager 模块的使用方式,但 flask 文档中的登录表单端点与我创建的不同,因此修改我的代码似乎是最好的解决方案。 I have my login endpoint code down below:我在下面有我的登录端点代码:

@app.route('/simpleuser')    //returns the user page where I have a logout button 
def simpleuser():
    return render_template('simple.html')


@app.route('/login' , methods = ['GET' , 'POST'])  
def login():
     if request.method == 'POST':
          loginuser = users.find_one({"Email":request.form['Email']}) //if email exists
          if loginuser: //if password matches a hashed password 
               if  bcrypt.check_password_hash(loginuser['Password'],request.form['Password']):
                   session['Email'] = request.form['Email']
                     if loginuser["User"]=="Simple":  
                         return redirect(url_for('simpleuser')) //my page where I can logout 
               return 'Invalid email/password combination'
          return 'Invalid email'
    return render_template('login.html')            



@app.route('/logout')
@login_required
def logout():
   # remove the email from the session if it's there
   session.pop('Email', None)
   return redirect(url_for('home')) 

I would appreciate your guidance with helping me logout from the page correctly.感谢您的指导,帮助我正确地从页面注销。 Thank you in advance先感谢您

It seems that by removing login_required the problem is immediatelly solved似乎通过删除 login_required 问题立即得到解决

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AttributeError: 'Flask' 对象没有属性 'login_manager' -- Login_Manager - AttributeError: 'Flask' object has no attribute 'login_manager' -- Login_Manager 出现错误:AttributeError: 'Flask' 对象没有属性 'login_manager' - Getting an error: AttributeError: 'Flask' object has no attribute 'login_manager' 我该如何解决错误:AttributeError: 'Flask' object has no attribute 'login_manager' - How can i fix the error: AttributeError: 'Flask' object has no attribute 'login_manager' 添加一行代码时出现此错误... AttributeError: 'Flask' object has no attribute 'login_manager' - I´m having this error when adding one line of code… AttributeError: 'Flask' object has no attribute 'login_manager' Flask-Login: AttributeError: type object 'User' 没有属性 'get' - Flask-Login: AttributeError: type object 'User' has no attribute 'get' AttributeError: 'Manager' 对象没有属性 - AttributeError: 'Manager' object has no attribute Flask-login AttributeError: 'User' 对象没有属性 'is_active' - Flask-login AttributeError: 'User' object has no attribute 'is_active' AttributeError: module 'flask_login.login_manager' has no attribute 'user_loader' when using Flask login without modal - AttributeError: module 'flask_login.login_manager' has no attribute 'user_loader' when using Flask login without modal Kivy - AttributeError: 'DialogContent' object 没有属性 'manager' - Kivy - AttributeError: 'DialogContent' object has no attribute 'manager' Flask AttributeError:“ unicode”对象没有属性“ tell” - Flask AttributeError: 'unicode' object has no attribute 'tell'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM