I have a Django ModelForm which exposes a multiple choice field corresponding to a many-to-many relation through a model which holds order
of selection (a list of documents) as an extra attribute. At the front-end, the field is displayed as two multiple select fields similar to that in admin, one to list available choices and the other holds the selected elements.
The form can be saved with the correct selection of elements but they are always in the order of the original order of choices, not the selection. The browser sends the selection in correct order, but order in form.cleaned_data['documents']
is always the order in original order of choices.
How can I make the MultipleChoiceField respect the order of elements selected?
Thanks.
cleaned_data['documents']
does not reflect the selection order in the select multiple field. I can re-order using the ids inrequest.GET.getlist('documents')
but feels hacky. – Cahoot