首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >金字塔+ FormAlchemy模型的改进

金字塔+ FormAlchemy模型的改进
EN

Stack Overflow用户
提问于 2012-03-14 00:23:37
回答 1查看 460关注 0票数 1

我目前有两个独立的模型(如下所示),这两个模型适用于我的应用程序的小规模/测试。然而,当有超过5000名客户时,通过FK下拉框进行搜索将会在每次输入注释时都会很麻烦。

我的问题是,有没有什么方法可以将Note模型放在我的客户模型中?这样我就可以从我的客户模型中直接添加备注了?

代码语言:javascript
复制
#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
EN

回答 1

Stack Overflow用户

发布于 2012-03-21 21:38:05

我没有找到任何方法来做这件事。

但是我对金字塔和形式化学还是很陌生的。

我已经决定编写我自己的管理/模型界面,让我用金字塔视图和jinja2模板做我需要做的事情。而不使用formalchemy和/或javascript。

我来自django,所以我没有意识到编写我自己的模型管理视图和模板是多么容易。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9687956

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档