[Fixed]-Why does my Django form show choice not available error?

1👍

When the form is being validated it checks whether the option exists in the choices for the field, in this case:

queryset=AutoType.objects.filter(brand=Brand.objects.first())

It works only when you select an option from the first brand.
To make it work you need to update the choices for the auto_type field before it validates the data or it might be easier not to limit the choices of auto_type to any brand and then update the select element in JavaScript when the page loads to show only the options of the first brand.

Leave a comment