16 lines
437 B
Python
16 lines
437 B
Python
from app import db
|
|
|
|
class Tag(db.Model):
|
|
__tablename__ = 'tag'
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
# Tagged post
|
|
post_id = db.Column(db.Integer, db.ForeignKey('post.id'), index=True)
|
|
post = db.relationship('Post', back_populates='tags', foreign_keys=post_id)
|
|
# Tag name
|
|
name = db.Column(db.String(64), index=True)
|
|
|
|
def __init__(self, post, tag):
|
|
self.post = post
|
|
self.name = tag
|