# HG changeset patch
# User Petr Marhoun <petr.marhoun@gmail.com>
# Date 1262727798 -3600
# Node ID 808774980dda1222ec10360e2fd53dc994402342
# Parent 905311cd1716f58b994115cf5a782de20bf536c7
[mq]: django-model-choice-field-validation.diff
diff --git a/django/forms/models.py b/django/forms/models.py
|
a
|
b
|
|
| 875 | 875 | |
| 876 | 876 | choices = property(_get_choices, ChoiceField._set_choices) |
| 877 | 877 | |
| 878 | | def clean(self, value): |
| 879 | | Field.clean(self, value) |
| | 878 | def to_python(self, value): |
| 880 | 879 | if value in EMPTY_VALUES: |
| 881 | 880 | return None |
| 882 | 881 | try: |
| … |
… |
|
| 886 | 885 | raise ValidationError(self.error_messages['invalid_choice']) |
| 887 | 886 | return value |
| 888 | 887 | |
| | 888 | def validate(self, value): |
| | 889 | return Field.validate(self, value) |
| | 890 | |
| 889 | 891 | class ModelMultipleChoiceField(ModelChoiceField): |
| 890 | 892 | """A MultipleChoiceField whose choices are a model QuerySet.""" |
| 891 | 893 | widget = SelectMultiple |