12 2017 档案

摘要:模型分离--让代码更方便管理 新建models.py,将模型定义全部放到这个独立的文件中。 from werkzeug.security import generate_password_hash,check_password_hash from datetime import datetime f 阅读全文
posted @ 2017-12-26 17:44 JaTae 阅读(136) 评论(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:30 JaTae 阅读(126) 评论(0) 推荐(0)
摘要:1、准备视图函数search()2、修改base.html 中搜索输入框所在的 3、完成视图函数search() 阅读全文
posted @ 2017-12-20 17:16 JaTae 阅读(163) 评论(0) 推荐(0)
摘要:个人中心—视图函数带标签页面参数tag@app.route('/usercenter/<user_id>/<tag>')def usercenter(user_id, tag): if tag == ‘1': return render_template('usercenter1.html', ** 阅读全文
posted @ 2017-12-19 15:16 JaTae 阅读(193) 评论(0) 推荐(0)
摘要:1、新页面userbase.html,用<ul ><li role="presentation"> 实现标签页导航。<ul class="nav nav-tabs"> <li role="presentation"><a href="#">Home</a></li> <li role="presen 阅读全文
posted @ 2017-12-15 15:01 JaTae 阅读(203) 评论(0) 推荐(0)
摘要:显示所有评论{% for foo in ques.comments %} 所有评论排序uquestion = db.relationship('Question', backref=db.backref('comments', order_by=creat_time.desc)) 显示评论条数{{ 阅读全文
posted @ 2017-12-13 20:04 JaTae 阅读(220) 评论(0) 推荐(0)
摘要:1.定义评论的视图函数@app.route('/comment/',methods=['POST'])def comment():读取前端页面数据,保存到数据库中 2.用<input type="hidden" 方法获取前端的"question_id" 3.显示评论次数 4.要求评论前登录 5.尝试 阅读全文
posted @ 2017-12-08 19:51 JaTae 阅读(169) 评论(0) 推荐(0)
摘要:主PY文件写视图函数,带id参数。 首页标题的标签做带参数的链接。 {{ url_for('detail',question_id = foo.id) }} 在详情页将数据的显示在恰当的位置。 建立评论的对象关系映射: class Comment(db.Model): __tablename__=' 阅读全文
posted @ 2017-12-06 22:26 JaTae 阅读(118) 评论(0) 推荐(0)
摘要:首页列表显示全部问答: 完成问答详情页布局: 在首页点击问答标题,链接到相应详情页。 阅读全文
posted @ 2017-12-05 20:25 JaTae 阅读(198) 评论(0) 推荐(0)
摘要:1. 在首页添加显示问答的列表,并定义好相应的样式。 无序列表 <ul > <li>Coffee</li> <li>Tea</li> <li>Milk</li> </ul> 2. 用字典向index.html传递参数。 阅读全文
posted @ 2017-12-01 11:41 JaTae 阅读(114) 评论(0) 推荐(0)