In Django I’m using a ChoiceField:
forms.py
class forms_sales_documents(forms.ModelForm):
sales_documents_description_1 = forms.ChoiceField(required=False, choices=list(models_products.objects.values_list( 'id_product','product_denomination')), widget=forms.Select(attrs={'id': 'sales_documents_editable_select_description_1','style': 'width:200px','onchange': 'populate_selected_product(this.id,this.value)'}))
I’m using JQuery-Editable-select
https://github.com/indrimuska/jquery-editable-select
to create searchable selectboxes but when I do, it becomes impossible to dissociate the ChoiceField value from the label.
They have to be the same like
models_products.objects.values_list( 'id_product','id_product'))
you can”t do something like
models_products.objects.values_list( 'id_product','product_denomination'))
otherwise the form won’t save and raise the error :
Select a valid choice. That choice is not one of the available choices
Anybody to help me on this ?