Which means association_proxy in the model sql_alchemy?

The question in the header, example code:
school = Table('school', metadata,
 Column('id', UUIDType(), primary_key=True),
 Column('title', String(255)),
)


class School:
 def __init__(self, title):
 self.id = uuid.uuid3(uuid.NAMESPACE_DNS, title)
 self.title = title
mapper(School, school)


education = Table('education', metadata,
 Column('school_id', UUIDType(), ForeignKey('school.id'), primary_key=True),
 Column('profile_id', UUIDType(), ForeignKey('profile.id'), primary_key=True),
 Column('start', DateTime),
 Column('end', DateTime),
)


class Education:
 title = association_proxy('school', 'title')
 def __init__(self, school_id=None, profile_id=None, start=None, end=None, profile=None
school=None):
 self.school_id = school_id or (school and school.id)
 self.profile_id = profile_id or (profile and profile.id)
 self.profile = profile
 self.school = school
 self.start = start
 self.end = end
mapper(Education, education, properties={
 'profile' : relationship(
Profile
backref=backref('education'),
),
 'school' : relationship(
School
backref=backref('education'),
),
})
March 20th 20 at 11:26
0 answer

Find more questions by tags DjangoSQLAlchemy