12 2017 档案

摘要:模型分离--让代码更方便管理 新建models.py,将模型定义全部放到这个独立的文件中。 新建exts.py,将db = SQLAlchemy()的定义放到这个独立的文件中。 models.py和主py文件,都从exts.py中导入db。 在主py文件中,对db进行始化,db.init_app(a 阅读全文
posted @ 2017-12-26 11:24 阿植 阅读(186) 评论(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 21:29 阿植 阅读(192) 评论(0) 推荐(0)
摘要:示例: Lobby.query.filter( or_( and_( Lobby.id == Team.lobby_id, LobbyPlayer.team_id == Team.id, LobbyPlayer.player_id == player.steamid ), and_( Lobby.i 阅读全文
posted @ 2017-12-20 16:33 阿植 阅读(171) 评论(0) 推荐(0)
摘要:detail.html 首页 阅读全文
posted @ 2017-12-19 17:12 阿植 阅读(204) 评论(0) 推荐(0)
摘要:新页面userbase.html,用 实现标签页导航。 Home Profile Messages 让userbase.html继承base.html。重写title,head,main块.将上述的样式放在head块,放在main块中.定义新的块user。 {% extends 'base.html' %} {% block title %} {% endblock %} {% blo... 阅读全文
posted @ 2017-12-16 21:56 阿植 阅读(221) 评论(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:48 阿植 阅读(388) 评论(0) 推荐(0)
摘要:定义评论的视图函数@app.route('/comment/',methods=['POST'])def comment():读取前端页面数据,保存到数据库中 @app.route('/comment/', methods=['POST']) @log def comment(): comment= 阅读全文
posted @ 2017-12-08 21:26 阿植 阅读(163) 评论(0) 推荐(0)
摘要:建立评论的对象关系映射: class Comment(db.Model): __tablename__='comment' 尝试实现发布评论。 阅读全文
posted @ 2017-12-07 11:51 阿植 阅读(243) 评论(0) 推荐(0)
摘要:首页列表显示全部问答: 将数据库查询结果传递到前端页面 Question.query.all() 前端页面循环显示整个列表。 问答排序 @app.route('/shouye/') def shouye(): context = { 'questions':Question.query.order_ 阅读全文
posted @ 2017-12-06 15:17 阿植 阅读(187) 评论(0) 推荐(0)
摘要:1. 在首页添加显示问答的列表,并定义好相应的样式。 无序列表 <ul > <li>Coffee</li> <li>Tea</li> <li>Milk</li> </ul> 2. 用字典向index.html传递参数。 from flask import Flask, render_template 阅读全文
posted @ 2017-12-01 21:23 阿植 阅读(153) 评论(0) 推荐(0)