1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

Fixed #12510. Changed ModelChoiceField to stop using some of its superclasses implementation. This could cause more than one query when generating choices. Thanks, Petr Marhoun and Honza Kral.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12211 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Joseph Kocherhans
2010-01-12 14:58:24 +00:00
parent eb2cbb6db1
commit 223b2721aa
2 changed files with 31 additions and 3 deletions

View File

@@ -903,8 +903,7 @@ class ModelChoiceField(ChoiceField):
choices = property(_get_choices, ChoiceField._set_choices)
def clean(self, value):
Field.clean(self, value)
def to_python(self, value):
if value in EMPTY_VALUES:
return None
try:
@@ -914,6 +913,9 @@ class ModelChoiceField(ChoiceField):
raise ValidationError(self.error_messages['invalid_choice'])
return value
def validate(self, value):
return Field.validate(self, value)
class ModelMultipleChoiceField(ModelChoiceField):
"""A MultipleChoiceField whose choices are a model QuerySet."""
widget = SelectMultiple