Skip to content

Instantly share code, notes, and snippets.

@silenius
Created April 5, 2018 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save silenius/f4f98acc372e228093298002c0736894 to your computer and use it in GitHub Desktop.
Save silenius/f4f98acc372e228093298002c0736894 to your computer and use it in GitHub Desktop.
'current_translation': orm.relationship(
ContentTranslation,
primaryjoin=lambda: sql.and_(
ContentTranslation.content_id == Content.id,
ContentTranslation.language_id == get_current_request().locale_name
),
lazy='joined',
uselist=False,
innerjoin=True,
viewonly=True
),
'translations': orm.relationship(
ContentTranslation,
back_populates='content',
cascade='all, delete-orphan',
#lazy='subquery',
collection_class=attribute_mapped_collection('language_id')
),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment