Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # in models
- class Template(Base):
- __tablename__ = 'template'
- id = Column(Integer, primary_key=True)
- description = Column(String(50))
- contenu = Column(Text)
- def __init__(self, description=None, contenu=None):
- self.description = description
- self.contenu = contenu
- def __repr__(self):
- return '<Template %r>' % (self.description)
- class Page(Base):
- __tablename__ = 'page'
- id = Column(Integer, primary_key=True)
- url = Column(String(50), unique=True)
- titre = Column(String(100))
- idTemplate = Column(Integer, ForeignKey('template.id'))
- def __init__(self, url=None, titre=None, idTemplate=0):
- self.url = url
- self.titre = titre
- self.contenu = contenu
- def __repr__(self):
- return '<Page %r>' % (self.titre)
- ## In My Views
- from dynamiqueweb.models import Page, Template
- retourPage = Page.query.filter_by(url='/').join(Template).first()
- # For Exemple i want to acces to variable contenu in my Template class and to my titre variable in Page
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement