models class Group(models.Model): name = models.CharField(max_length=128) class User(models.Model): name = models.CharField(max_length=128) group = models.ForeignKey(Group) user = User.objects.filter(name='admin').get()
ForeignKey from sqlalchemy.orm import relationship, backref from sqlalchemy.ext.declarative import declarative_base import sqlalchemy as sa Base = declarative_base() class Group(Base): __tablename__ = 'group' id = Column(sa.Integer, primary_key=True) name = Column(sa.String(128)) O/R マッパー