代码拉取完成,页面将自动刷新
from exts import db
from datetime import datetime
class EmailCaptchaModel(db.Model):
__tablename__ = "email_captcha"
id = db.Column(db.Integer,primary_key=True,autoincrement=True)
email = db.Column(db.String(100),unique=True)
captcha = db.Column(db.String(10))
create_time = db.Column(db.DateTime,default=datetime.now)
class UserModel(db.Model):
__tablename__ = "user"
id = db.Column(db.Integer,primary_key=True,autoincrement=True)
username = db.Column(db.String(200),unique=True)
email = db.Column(db.String(100),unique=True)
password = db.Column(db.String(200))
join_time = db.Column(db.DateTime,default=datetime.now)
# 问题模块
class QuestionModel(db.Model):
__tablename__ = "question"
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
title = db.Column(db.String(200))
content = db.Column(db.Text)
create_time = db.Column(db.DateTime,default=datetime.now)
author_id = db.Column(db.Integer,db.ForeignKey("user.id"))
author = db.relationship("UserModel",backref="questions")
# 问答模型
class AnswerModel(db.Model):
__tablename__ = "answer"
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
content = db.Column(db.Text)
create_time = db.Column(db.DateTime,default=datetime.now)
question_id = db.Column(db.Integer,db.ForeignKey("question.id"))
author_id = db.Column(db.Integer, db.ForeignKey("user.id"))
question = db.relationship("QuestionModel",backref=db.backref("answers",order_by=create_time.desc()))
author = db.relationship("UserModel",backref="answers")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。