我正在使用烧瓶不安分并尝试发帖为多对多关系创建新记录
Categories = db.Table('categories',
db.Column(
'help_request_id', db.Integer, db.ForeignKey('help_request.id')),
db.Column('category_id', db.Unicode(20), db.ForeignKey('category.id')))
class Category(db.Model):
id = db.Column(db.Unicode(20), primary_key=True)
eng_name = db.Column(db.Unicode(50))
created_by_user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
created_by = db.relationship(User)
create_date = db.Column(db.DateTime, default=datetime.now)
imagePath = db.Column(db.Unicode(128))
# Required for administrative interface
def __unicode__(self):
return self.eng_name
class HelpRequest(db.Model):
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.Unicode(100))
categories = db.relationship('Category', secondary=categories,
backref=db.backref('helprequests', lazy='dynamic'))
我如何发布带有指定类别的帮助请求?谢谢
亚历克斯