开发者

django - model form with 'helper select'

开发者 https://www.devze.com 2023-03-28 10:41 出处:网络
I\'m looking for best solution for this issue: I\'have a Model like this: class annotation(models.Model):

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

精彩评论

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

关注公众号