How to make a multiple select in django

0

Good evening I need to implement a multiple select in django and store the selected options in the model.

I appreciate the ideas that you give me since I am in need of this functionality.

    
asked by jhon1946 28.02.2017 в 03:27
source

1 answer

2

Django already has a field for that. The only thing that is done is to define the widget, so it would be something like this:

OPTIONS = (
    ("OP1","Opcion 1"),
    ("OP2","Opcion 2"),
    ("OP3","OPcion 3"),
)

field = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple, choices=OPTIONS
    
answered by 28.02.2017 / 07:41
source