mirror of https://github.com/django/django.git
Made use of `EMPTY_VALUES` in `ModelChoiceField.clean()`.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6699 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
66576c285a
commit
42c5a91388
|
@ -9,7 +9,7 @@ from django.utils.datastructures import SortedDict
|
||||||
|
|
||||||
from util import ValidationError
|
from util import ValidationError
|
||||||
from forms import BaseForm
|
from forms import BaseForm
|
||||||
from fields import Field, ChoiceField
|
from fields import Field, ChoiceField, EMPTY_VALUES
|
||||||
from widgets import Select, SelectMultiple, MultipleHiddenInput
|
from widgets import Select, SelectMultiple, MultipleHiddenInput
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
|
@ -200,7 +200,7 @@ class ModelChoiceField(ChoiceField):
|
||||||
|
|
||||||
def clean(self, value):
|
def clean(self, value):
|
||||||
Field.clean(self, value)
|
Field.clean(self, value)
|
||||||
if value in ('', None):
|
if value in EMPTY_VALUES:
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
value = self.queryset.get(pk=value)
|
value = self.queryset.get(pk=value)
|
||||||
|
|
Loading…
Reference in New Issue