﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
32347	ModelChoiceField does not provide value of invalid choice when raising ValidationError	Aaron Wiegel	Jerin Peter George	"Compared with `ChoiceField` and others, `ModelChoiceField` does not show the value of the invalid choice when raising a validation error. Passing in parameters with the invalid value and modifying the default error message for the code `invalid_choice` should fix this.

From source code:


{{{
class ModelMultipleChoiceField(ModelChoiceField):
    """"""A MultipleChoiceField whose choices are a model QuerySet.""""""
    widget = SelectMultiple
    hidden_widget = MultipleHiddenInput
    default_error_messages = {
        'invalid_list': _('Enter a list of values.'),
        'invalid_choice': _('Select a valid choice. %(value)s is not one of the'
                            ' available choices.'),
        'invalid_pk_value': _('“%(pk)s” is not a valid value.')
    }
    ...

}}}



{{{
class ModelChoiceField(ChoiceField):
    """"""A ChoiceField whose choices are a model QuerySet.""""""
    # This class is a subclass of ChoiceField for purity, but it doesn't
    # actually use any of ChoiceField's implementation.
    default_error_messages = {
        'invalid_choice': _('Select a valid choice. That choice is not one of'
                            ' the available choices.'),
    }
    ...
}}}
"	New feature	closed	Forms	4.0	Normal	fixed			Ready for checkin	1	0	0	0	0	0
