Django OneToMany form on related model
I've created a onetomany relationship between two models. The model that has the foreignkey I can use their formset without problems, but now I want to fill th开发者_JAVA百科is relation through the form of the model that has the "many", I know I can retrieve it using the *_set, but how can I create a MultipleChoiceField form element of this data?
Thanks for any help!
Regards,
Thiago
Have a look at the docs for fields which handle relationships. You could use a ModelMultipleChoiceField
-- it's essentially a MultipleChoiceField
that takes its choices from a queryset.
精彩评论