bbhj3434's recent timeline updates
bbhj3434

bbhj3434

V2EX member #58405, joined on 2014-03-18 11:07:47 +08:00
bbhj3434's recent replies
Mar 22, 2014
Replied to a topic by bbhj3434 Python Flask-sqlalchemy 自身引用的写法?
@bbhj3434 打错字,应该是检查外键成立

class Category(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(255), nullable=False, unique=True)
top = db.Column(db.Boolean, nullable=False)
on_id = db.Column(db.Integer, db.ForeignKey('category.id'))
top_category = db.relationship('Category', backref='sub_category', remote_side=[id])

我现在的表如上,可是有个问题:on_id 这个字段随意一个不存在的id或空值都可以写入。。。
ForeignKey 这个有 required 这种参数吗?
Mar 22, 2014
Replied to a topic by bbhj3434 Python Flask-sqlalchemy 自身引用的写法?
@yinian1992 >_< 感谢你的帮助呢~还有一个问题,ForeignKey 有 类似 required 这个必定要输入值的参数吗?找一下没有说到这个,只有 nullable
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3767 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 18ms · UTC 04:19 · PVG 12:19 · LAX 21:19 · JFK 00:19
♥ Do have faith in what you're doing.