[Flask] Populating child models with parent model Fields in Views

Scott Werner scott.werner.vt at gmail.com
Fri Mar 3 15:43:05 EST 2017

Assuming  a One to Many relationship:

class Parent(Base):
    __tablename__ = 'parent'
    id = Column(Integer, primary_key=True)
    children = relationship("Child", backref="parent")

class Child(Base):
    __tablename__ = 'child'
    id = Column(Integer, primary_key=True)
    parent_id = Column(Integer, ForeignKey('parent.id'))

child = Child()
parent = Parent()


Scott Werner
scott.werner.vt at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20170303/52e83fdc/attachment.html>

More information about the Flask mailing list