Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View test.diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
diff -ur -x '*.pyc' django-django-a9fa3d4/django/core/checks/compatibility/django_1_6_0.py tb123-django-553c91a/django/core/checks/compatibility/django_1_6_0.py
--- django-django-a9fa3d4/django/core/checks/compatibility/django_1_6_0.py 2014-08-03 02:02:06.000000000 +0200
+++ tb123-django-553c91a/django/core/checks/compatibility/django_1_6_0.py 2014-08-08 01:20:16.000000000 +0200
@@ -10,7 +10,7 @@
def check_1_6_compatibility(**kwargs):
errors = []
errors.extend(_check_test_runner(**kwargs))
- errors.extend(_check_boolean_field_default_value(**kwargs))
+ #errors.extend(_check_boolean_field_default_value(**kwargs))
return errors
diff -ur -x '*.pyc' django-django-a9fa3d4/django/db/models/fields/__init__.py tb123-django-553c91a/django/db/models/fields/__init__.py
--- django-django-a9fa3d4/django/db/models/fields/__init__.py 2014-08-03 02:02:06.000000000 +0200
+++ tb123-django-553c91a/django/db/models/fields/__init__.py 2014-08-08 01:03:40.000000000 +0200
@@ -932,37 +932,12 @@
}
description = _("Boolean (Either True or False)")
- def __init__(self, *args, **kwargs):
- kwargs['blank'] = True
- super(BooleanField, self).__init__(*args, **kwargs)
-
- def check(self, **kwargs):
- errors = super(BooleanField, self).check(**kwargs)
- errors.extend(self._check_null(**kwargs))
- return errors
-
- def _check_null(self, **kwargs):
- if getattr(self, 'null', False):
- return [
- checks.Error(
- 'BooleanFields do not accept null values.',
- hint='Use a NullBooleanField instead.',
- obj=self,
- id='fields.E110',
- )
- ]
- else:
- return []
-
- def deconstruct(self):
- name, path, args, kwargs = super(BooleanField, self).deconstruct()
- del kwargs['blank']
- return name, path, args, kwargs
-
def get_internal_type(self):
return "BooleanField"
def to_python(self, value):
+ if value is None:
+ return value
if value in (True, False):
# if value is 1 or 0 than it's equal to True or False, but we want
# to return a true bool for semantic reasons.
@@ -993,16 +968,17 @@
return bool(value)
def formfield(self, **kwargs):
- # Unlike most fields, BooleanField figures out include_blank from
- # self.null instead of self.blank.
- if self.choices:
- include_blank = (self.null or
- not (self.has_default() or 'initial' in kwargs))
- defaults = {'choices': self.get_choices(include_blank=include_blank)}
+ if self.blank or self.choices:
+ return super(BooleanField, self).formfield(**kwargs)
else:
- defaults = {'form_class': forms.BooleanField}
- defaults.update(kwargs)
- return super(BooleanField, self).formfield(**defaults)
+ # In the checkbox case, 'required' means "must be checked (=> true)",
+ # which is different from the choices case ("must select some value").
+ # Since we want to allow both True and False (checked/unchecked) choices,
+ # set 'required' to False.
+ defaults = {'form_class': forms.BooleanField,
+ 'required': False}
+ defaults.update(kwargs)
+ return super(BooleanField, self).formfield(**defaults)
class CharField(Field):
@@ -1867,13 +1843,7 @@
return super(GenericIPAddressField, self).formfield(**defaults)
-class NullBooleanField(Field):
- empty_strings_allowed = False
- default_error_messages = {
- 'invalid': _("'%(value)s' value must be either None, True or False."),
- }
- description = _("Boolean (Either True, False or None)")
-
+class NullBooleanField(BooleanField):
def __init__(self, *args, **kwargs):
kwargs['null'] = True
kwargs['blank'] = True
@@ -1885,43 +1855,7 @@
del kwargs['blank']
return name, path, args, kwargs
- def get_internal_type(self):
- return "NullBooleanField"
-
- def to_python(self, value):
- if value is None:
- return None
- if value in (True, False):
- return bool(value)
- if value in ('None',):
- return None
- if value in ('t', 'True', '1'):
- return True
- if value in ('f', 'False', '0'):
- return False
- raise exceptions.ValidationError(
- self.error_messages['invalid'],
- code='invalid',
- params={'value': value},
- )
-
- def get_prep_lookup(self, lookup_type, value):
- # Special-case handling for filters coming from a Web request (e.g. the
- # admin interface). Only works for scalar values (not lists). If you're
- # passing in a list, you might as well make things the right type when
- # constructing the list.
- if value in ('1', '0'):
- value = bool(int(value))
- return super(NullBooleanField, self).get_prep_lookup(lookup_type,
- value)
-
- def get_prep_value(self, value):
- value = super(NullBooleanField, self).get_prep_value(value)
- if value is None:
- return None
- return bool(value)
-
- def formfield(self, **kwargs):
+ def __unused_formfield(self, **kwargs):
defaults = {
'form_class': forms.NullBooleanField,
'required': not self.blank,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.