摘要:模型分离--让代码更方便管理 新建models.py,将模型定义全部放到这个独立的文件中。 新建exts.py,将db = SQLAlchemy()的定义放到这个独立的文件中。 models.py和主py文件,都从exts.py中导入db。 在主py文件中,对db进行始化,db.init_app(a
阅读全文
摘要:1.更新User对象,设置对内的_password class User(db.Model): __tablename__ = 'user' _password = db.Column(db.String(200), nullable=False) #内部使用 from werkzeug.secur
阅读全文
摘要:示例: Lobby.query.filter( or_( and_( Lobby.id == Team.lobby_id, LobbyPlayer.team_id == Team.id, LobbyPlayer.player_id == player.steamid ), and_( Lobby.i
阅读全文
摘要:个人中心—视图函数带标签页面参数tag@app.route('/usercenter/<user_id>/<tag>')def usercenter(user_id, tag): if tag == ‘1': return render_template('usercenter1.html', **
阅读全文
摘要:新页面userbase.html,用 实现标签页导航。 Home Profile Messages {% extends 'user.html' %} {% block title %}-全部问题{% endblock %} {% block body %} ...
阅读全文
摘要:显示所有评论{% for foo in ques.comments %} <ul class="list-unstyled" style="width: 900px"> {% for foo in comments %} <li class="list-group-item"> <a href="{
阅读全文
摘要:定义评论的视图函数 @app.route('/comment/',methods=['POST'])def comment():读取前端页面数据,保存到数据库中 用',methods=['GET','POST']) def detail(question_id): quest=Question.query.filter(Question.id == question_id).first(...
阅读全文
摘要:建立评论的对象关系映射: class Comment(db.Model): __tablename__='comment' 尝试实现发布评论。
阅读全文
摘要:1. 在首页添加显示问答的列表,并定义好相应的样式。 无序列表 Coffee Tea Milk 2. 用字典向index.html传递参数。
阅读全文