8

Based on the form below, I would like to know If Is there a way (or a plugin) to use the field tipo_indicador to filter indicadores field:

tipo_indicador = forms.ModelChoiceField(
    queryset=TipoIndicador.objects.all(),
    label=u'Tipo de indicador',
    required=False,
)

indicadores = forms.ModelMultipleChoiceField(
    label= _(u'Indicadores'),
    required=False,
    queryset=Indicador.objects.all(),
    widget=admin_widgets.FilteredSelectMultiple(verbose_name=_(u'indicadores'), is_stacked=False)
)
Dharman
  • 30,962
  • 25
  • 85
  • 135
  • 1
    You have to use `ajax`. – albar Mar 08 '18 at 14:03
  • on change value get data from ajax call. – SuReSh Mar 08 '18 at 14:11
  • @albar do you have an example? – Rafael Pinheiro Mar 08 '18 at 14:12
  • I've found this one: https://stackoverflow.com/questions/43939201/dynamically-update-django-form-field-options-using-ajax-to-get-new-queryset I'll try. – Rafael Pinheiro Mar 08 '18 at 14:40
  • I'm voting to close this question as off-topic because it belongs to https://pt.stackoverflow.com/ – cezar Mar 08 '18 at 14:55
  • Please look into these django plugins - https://github.com/digi604/django-smart-selects. https://django-autocomplete-light.readthedocs.io/en/master/. Specific content - https://django-autocomplete-light.readthedocs.io/en/master/tutorial.html#filtering-results-based-on-the-value-of-other-fields-in-the-form – Mohit Rustagi Oct 30 '18 at 19:28

0 Answers0