Closed abhishek-ntt closed 4 years ago
Hi @abhishek-ntt,
thanks for reaching out. I believe you are seeing this validation error, because you didn't pass any choices to your forms.ChoiceField
. So even if the widget shows choices, the Django's form validation will think they are not valid. I would advise you to use a forms.ModelChoiceField
and also pass the same queryset, that you pass to the widget queryset=Customer.objects.all().exclude(is_active=False)
.
I hope that solves your problem. If not, please reach out any time.
Best -Joe
Hi, I'm writing a form @applegrew
forms/invoices.py
template - templates/invoice/list.html
and a class based view views/invoices/listings.py
Application is running and we can see the Customer dropdown box and if we enter 2 letters it will start displaying the customers with those letters and once we select the customer and click on submit button, it is showing the error as Select a valid choice. 814 is not one of the available choices. But it is a valid customer id and there is a database record and after submit, the selected option is not selected in the form.