| 2 | |
| 3 | From source code: |
| 4 | |
| 5 | |
| 6 | {{{ |
| 7 | class ModelMultipleChoiceField(ModelChoiceField): |
| 8 | """A MultipleChoiceField whose choices are a model QuerySet.""" |
| 9 | widget = SelectMultiple |
| 10 | hidden_widget = MultipleHiddenInput |
| 11 | default_error_messages = { |
| 12 | 'invalid_list': _('Enter a list of values.'), |
| 13 | 'invalid_choice': _('Select a valid choice. %(value)s is not one of the' |
| 14 | ' available choices.'), |
| 15 | 'invalid_pk_value': _('ā%(pk)sā is not a valid value.') |
| 16 | } |
| 17 | ... |
| 18 | |
| 19 | }}} |
| 20 | |
| 21 | |
| 22 | |
| 23 | {{{ |
| 24 | class ModelChoiceField(ChoiceField): |
| 25 | """A ChoiceField whose choices are a model QuerySet.""" |
| 26 | # This class is a subclass of ChoiceField for purity, but it doesn't |
| 27 | # actually use any of ChoiceField's implementation. |
| 28 | default_error_messages = { |
| 29 | 'invalid_choice': _('Select a valid choice. That choice is not one of' |
| 30 | ' the available choices.'), |
| 31 | } |
| 32 | ... |
| 33 | }}} |