1
私は現在、小規模な/テストで私のアプリケーションでうまく動作する2つの別々のモデル(下記参照)を持っています。しかし、5000人以上の顧客がFKドロップダウンボックスで検索すると、メモが入力されるたびに煩わしいことになります。ピラミッド+ FormAlchemyモデルの改善
私の質問は、どうにか私の顧客モデルの中にノートモデルを置くことができますか?私の顧客モデルの中から直接メモを追加できるようにするには?
#models.py
samples_to_customer = Table('samples_to_customer', Base.metadata,
Column('customer_id', Integer, ForeignKey('customer.id')),
Column('sample_id', Integer, ForeignKey('samples.id'))
)
#Create a cusotmer model to store customer numbers
class Customer(Base):
__tablename__ = 'customer'
__acl__ = [
(Allow, 'admin', ALL_PERMISSIONS),
(Allow, 'saff', ('view', 'edit')),
]
id = Column(Integer, primary_key=True)
name = Column(Unicode, unique=True) #this will be the variable used to search the existing db
customer_samples = relationship('Sample', secondary='samples_to_customer', backref='samples')
sales_rep = Column(Integer, ForeignKey('rep.id'))
rep = relationship('Rep', backref='rep')
def __unicode__(self):
return self.name
# This model will have its own entry view/page a user logs on and enters notes (according to a customer
# number) they then get stored/saved onto the Customers account
class Note(Base):
__tablename__ = 'note'
__acl__ = [
(Allow, 'admin', ALL_PERMISSIONS),
(Allow, 'staff', ('view', 'edit')),
]
id = Column(Integer, primary_key=True)
name = Column(Unicode)
pub_date = Column(Date)
customer_no = Column(Integer, ForeignKey('customer.id'))
customer = relationship('Customer', backref='notes')
def __unicode__(self):
return self.name