Commits

Atsushi Odagiri  committed d0ff635

change demo model to many-to-many relationship.

  • Participants
  • Parent commits edc8885

Comments (0)

Files changed (1)

File src/alchemyadmin/demo/__init__.py

 Base = declarative_base()
 metadata = Base.metadata
 
+user_job_table = Table('user_job', metadata,
+                       Column('user_id', Integer, 
+                              ForeignKey('user.user_id')),
+                       Column('job_id', Integer,
+                              ForeignKey('job.job_id')))
+
 class User(Base):
     __tablename__ = 'user'
     user_id = Column(Integer, primary_key=True)
     display_name = Column(Unicode(255))
     description = Column(UnicodeText)
     birthday = Column(DateTime)
-    job_id = Column(Integer, ForeignKey('job.job_id'))
-    job = relation("Job", backref='users')
+    job = relation("Job", backref='users', secondary=user_job_table)
 
 
     def __unicode__(self):