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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user