Django dependent select

前端 未结 3 726
青春惊慌失措
青春惊慌失措 2020-12-03 11:58

I know that there is a lot of answers on this question, but i am new in Django and i dont know how to implement these solutions. First what i want to do. This is my models:<

3条回答
  •  不思量自难忘°
    2020-12-03 12:38

    I got fed up with the non-DRY solutions to this, so I wrote something maybe flexible enough for most use cases:

    django-related-select

    Right now it only handles online/AJAX related select boxes. I eventually plan (maybe this week or next) to add an offline mode that pushes a bit of rendered JS with the widget to track the onchange event of the parent and translate it to the child choices via a map of value -> list(choices). The AJAX solution is great for things like car make/model (1000s of choices) while the offline solution is great for product/color (maybe 10s of choices).

提交回复
热议问题