Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #6212 -- Give models.NullBooleanField the right default newform…

…s field. Patch from SmileyChris.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6935 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 9229c34163982320db6f9ee4473964699893d79f 1 parent 931764d
@malcolmt malcolmt authored
Showing with 9 additions and 4 deletions.
  1. +9 −4 django/db/models/fields/__init__.py
View
13 django/db/models/fields/__init__.py
@@ -710,7 +710,7 @@ def formfield(self, **kwargs):
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 @@ def to_python(self, value):
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 @@ def formfield(self, **kwargs):
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 @@ def get_manipulator_field_objs(self):
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):
Please sign in to comment.
Something went wrong with that request. Please try again.