2012-03-13 2 views
1

현재 두 개의 모델 (아래 참조)이 있습니다.이 모델은 소규모/테스트의 응용 프로그램에서 잘 작동합니다. 그러나 5000 명이 넘는 고객이 FK 드롭 다운 상자를 통해 검색하면 메모를 입력 할 때마다 귀찮을 수 있습니다.피라미드 + FormAlchemy 모델 개선

제 질문은 고객 모델에 Note 모델을 넣을 수 있습니까? 고객 모델 내부에서 직접 메모를 추가 할 수 있습니까?

#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 

답변

1

어쨌든 todo this를 찾지 못했습니다.

그러나 나는 여전히 피라미드와 formalchemy에 새로운 있습니다.

피라미드보기 및 jinja2 템플릿과 관련하여 필자가 직접 할 수있는 고유 한 관리자/모델 인터페이스를 작성하기로 결정했습니다. formalchemy 및/또는 javascript를 사용하지 않고.

나는 장고에서 왔기 때문에 내 자신의 모델 관리자보기 및 템플릿을 작성하는 것이 얼마나 쉬운 지 알지 못했습니다.