12 2017 档案

摘要:模型分离--让代码更方便管理 新建models.py,将模型定义全部放到这个独立的文件中。 models.py和主py文件,都从exts.py中导入db。 新建exts.py,将db = SQLAlchemy()的定义放到这个独立的文件中。 在主py文件中,对db进行始化,db.init_app(a 阅读全文

posted @ 2017-12-28 10:14 043李庆 阅读(201) 评论(0) 推荐(0)

摘要:1.更新User对象,设置对内的_password class User(db.Model): __tablename__ = 'user' _password = db.Column(db.String(200), nullable=False) #内部使用 2.编写对外的password fro 阅读全文

posted @ 2017-12-22 11:26 043李庆 阅读(214) 评论(0) 推荐(0)

摘要:1、准备视图函数search() 2、修改base.html 中搜索输入框所在的 <form action="{{ url_for('search') }}" method="get"> <input name="q" type="text" placeholder="请输入关键字"> 3、完成视图 阅读全文

posted @ 2017-12-19 11:57 043李庆 阅读(207) 评论(0) 推荐(0)

摘要: 提交作业 1、个人中心—视图函数带标签页面参数tag@app.route('/usercenter/<user_id>/<tag>')def usercenter(user_id, tag): if tag == ‘1': return render_template('usercenter1. 阅读全文

posted @ 2017-12-15 10:36 043李庆 阅读(200) 评论(0) 推荐(0)

摘要:1、新页面user.html,用<ul ><li role="presentation"> 实现标签页导航。<ul class="nav nav-tabs"> <li role="presentation"><a href="#">Home</a></li> <li role="presentati 阅读全文

posted @ 2017-12-13 20:11 043李庆 阅读(260) 评论(0) 推荐(0)

摘要:1、显示所有评论{% for foo in ques.comments %} 2、所有评论排序uquestion = db.relationship('Question', backref=db.backref('comments', order_by=creat_time.desc)) 3、显示评 阅读全文

posted @ 2017-12-12 12:43 043李庆 阅读(262) 评论(0) 推荐(0)

摘要:1、定义评论的视图函数 @app.route('/comment/',methods=['POST']) def comment(): 读取前端页面数据,保存到数据库中 2、用<input type="hidden" 方法获取前端的"question_id" 3、显示评论次数 4、要求评论前登录 5 阅读全文

posted @ 2017-12-08 17:45 043李庆 阅读(157) 评论(0) 推荐(0)

摘要:主PY文件写视图函数,带id参数。 @app.route('/detail/<question_id>') def detail(question_id): quest = return render_template('detail.html', ques = quest) 首页标题的标签做带参数 阅读全文

posted @ 2017-12-06 00:35 043李庆 阅读(124) 评论(0) 推荐(0)

摘要:首页列表显示全部问答: 将数据库查询结果传递到前端页面 Question.query.all() 前端页面循环显示整个列表。 问答排序 完成问答详情页布局: 包含问答的全部信息 评论区 以往评论列表显示区。 在首页点击问答标题,链接到相应详情页。 阅读全文

posted @ 2017-12-01 12:07 043李庆 阅读(119) 评论(0) 推荐(0)

导航