GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing code.djangoproject.com — #32347 (ModelChoiceField does not provide value of invalid choice when raising ValidationError) – Django IssuesOpened 6 years ago Closed 6 years ago #32347 closed New feature (fixed)ModelChoiceField does not provide value of invalid choice when raising ValidationError
Description (last modified by Aaron Wiegel)
Compared with
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.'),
}
...
Change History (10)comment:1 by Aaron Wiegel, 6 years ago
comment:2 by Aaron Wiegel, 6 years ago
follow-up: 4 comment:3 by Carlton Gibson, 6 years ago
This message has been the same literally forever b2b6fc8e3c78671c8b6af2709358c3213c84d119.
Given that ChoiceField passes the value when raising the error, if you set error_messages you should be able to get the result you want. in reply to: 3 comment:4 by Aaron Wiegel, 6 years ago
Replying to Carlton Gibson:
That is comment:5 by Aaron Wiegel, 6 years ago
comment:6 by Carlton Gibson, 6 years ago
OK, if you want to look at submitting a PR we can see if any objections come up in review. Thanks. comment:7 by Jerin Peter George, 6 years ago
comment:8 by Mariusz Felisiak, 6 years ago
comment:9 by Mariusz Felisiak, 6 years ago
comment:10 by Mariusz Felisiak <felisiak.mariusz@…>, 6 years ago
Note:
See TracTickets
for help on using tickets.
Download in other formats: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |