Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

To ensure that a model BooleanField has an explicit value set (and si…

…nce it's

not required, by default), set the default properly in the constructor.

This code can be simplified when/if we resolve the
BooleanField/NullBooleanField overlap, but the current stuff is backwards
compatible. This would previously cause SQL errors on PostgreSQL and
interesting failures in subtle ways on MySQL and SQLite.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 6ef47cfe5fe728bcc0290543eccd87e63c11d6a1 1 parent c51d000
@malcolmt malcolmt authored
Showing with 2 additions and 0 deletions.
  1. +2 −0  django/db/models/fields/
2  django/db/models/fields/
@@ -477,6 +477,8 @@ def formfield(self, **kwargs):
class BooleanField(Field):
def __init__(self, *args, **kwargs):
kwargs['blank'] = True
+ if 'default' not in kwargs and not kwargs.get('null'):
+ kwargs['default'] = False
Field.__init__(self, *args, **kwargs)
def get_internal_type(self):

0 comments on commit 6ef47cf

Please sign in to comment.
Something went wrong with that request. Please try again.