2011-10-19 23 views
0

我想在django中構建一個複雜的表格,它可以將多個模型元素組合到一個單獨的html頁面中。我找到了一些關於如何爲單個模型元素構建頁面的示例。 Filemaker提供了這種功能,但我無法將此轉化爲Filemaker。如果可能的話,我想使用django。在django中尋求多表格示例

例如,puposes,我建立了一個汽車銷售模型。每個人都非常瞭解與購買汽車有關的多個領域。實際的模型並不那麼幹淨。在示例模型中,用戶是銷售人員。當用戶登錄時,他們會看到他們的客戶屏幕。我試圖將大量相關數據放在一個頁面上,而不是讓用戶瀏覽多個頁面。

是否有可能建立一個單一的表單來做到這一點? django是否提供任何東西 使這比建立大量自定義html表單更容易?有人知道有一個類似的例子嗎?

-----------我的佈局--------------

<table> 
    <tr><td> Top Left: Basic Customer info </td> 
     <td> Top Right: Wish List info. They want, but probably can't buy. </td> 
     <td rowspan=2> A great big scrollable list of all customers </td> 
    </tr> 
    <tr><td>Bottom Left: Sales Person info about himself </td> 
     <td>Bottom Right: A big notes section from the selected customer</td> 
    </tr> 
</table> 

-----------我模型--------------

# Bottom Left Panel 
class SalesPersonProfile(models.Model): 
    user = models.ForeignKey(User, unique=True) 
    company = models.CharField(max_length=50, blank=True) 
    addr = models.CharField(max_length=50, blank=True) 
    city = models.CharField(max_length=25) 
    state = models.CharField(max_length=2) 
    zipCode = models.CharField(max_length=8) 

# Top Left Panel Information 
# Also a list of this stuff that goes in the extreme right 
class Customer(models.Model): 
    salesPerson = models.ForeignKey(User, editable = False) 
    lastName = models.CharField(max_length=20) 
    firstName = models.CharField(max_length=20) 
    address = models.CharField(max_length=50) 
    city = models.CharField(max_length=25) 
    state = models.CharField(max_length=2) 
    zip = models.CharField(max_length=8) 
    image = models.ImageField(upload_to='photos') 

    # BOTTOM RIGHT - A great big multi-line notes field 
    notes = models.TextField(null=True, blank=True) 

# Top Right Info 
class WishList(models.Model): 
    customer = models.ForeignKey(Customer, unique=True) 
    dtg = models.DateTimeField('Date Added') 
    carType = models.CharField(max_length=10, choices=CAR_TYPE) 
    year = models.CharField(max_length=4) 
    make = models.CharField(max_length=20) 
    model = models.CharField(max_length=20) 
    miles = models.CharField(max_length=20) 
    color = models.CharField(max_length=20) 

回答

0

嘗試創建一個表格,你需要的所有字段,然後ovveride保存,驗證等形式方法