开发者

django - model form with 'helper select'

I'm looking for best solution for this issue:

I'have a Model like this:

class annotation(models.Model):
    product = models.ForeignKey(Product, ... )
    annotation =  models.TextField( ...

A form for this Model may be:

product: [ a select to chose a product ]
annotations: [ a input type text ]

But, because product table is big, I show a previous select to user:

product family: [ a select to chose a product family ]
product: [ a select to chose a product in selected product family ]
annotations: [ a input type text ]

(Product family is another model and product has a foreign开发者_开发知识库 key to it)

My first solution was to write a new widget called SelectAjax and use it on ModelChoiceField. It works fine, but is not an elegant solution for me.

Can someone propose an alternative?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜