From 9229c34163982320db6f9ee4473964699893d79f Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Mon, 17 Dec 2007 10:35:53 +0000 Subject: [PATCH] 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 --- django/db/models/fields/__init__.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 7eb57d96c9..139a096b68 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -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):