Fixed #6212 -- Give models.NullBooleanField the right default newforms field. Patch from SmileyChris.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6935 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2007-12-17 10:35:53 +00:00
parent 931764ddb5
commit 9229c34163
1 changed files with 9 additions and 4 deletions

View File

@ -710,7 +710,7 @@ class EmailField(CharField):
class FileField(Field):
def __init__(self, verbose_name=None, name=None, upload_to='', **kwargs):
self.upload_to = upload_to
kwargs['max_length'] = kwargs.get('max_length', 100)
kwargs['max_length'] = kwargs.get('max_length', 100)
Field.__init__(self, verbose_name, name, **kwargs)
def get_db_prep_save(self, value):
@ -906,6 +906,11 @@ class NullBooleanField(Field):
def get_manipulator_field_objs(self):
return [oldforms.NullBooleanField]
def formfield(self, **kwargs):
defaults = {'form_class': forms.NullBooleanField}
defaults.update(kwargs)
return super(NullBooleanField, self).formfield(**defaults)
class PhoneNumberField(IntegerField):
def get_manipulator_field_objs(self):
return [oldforms.PhoneNumberField]
@ -922,11 +927,11 @@ class PhoneNumberField(IntegerField):
class PositiveIntegerField(IntegerField):
def get_manipulator_field_objs(self):
return [oldforms.PositiveIntegerField]
def formfield(self, **kwargs):
defaults = {'min_value': 0}
defaults.update(kwargs)
return super(PositiveIntegerField, self).formfield(**defaults)
return super(PositiveIntegerField, self).formfield(**defaults)
class PositiveSmallIntegerField(IntegerField):
def get_manipulator_field_objs(self):
@ -935,7 +940,7 @@ class PositiveSmallIntegerField(IntegerField):
def formfield(self, **kwargs):
defaults = {'min_value': 0}
defaults.update(kwargs)
return super(PositiveSmallIntegerField, self).formfield(**defaults)
return super(PositiveSmallIntegerField, self).formfield(**defaults)
class SlugField(CharField):
def __init__(self, *args, **kwargs):