Created
August 7, 2014 23:31
-
-
Save jonashaag/d8a9f82d88c60c103189 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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