Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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: http://code.djangoproject.com/svn/django/trunk@8050 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 6ef47cfe5fe728bcc0290543eccd87e63c11d6a1 1 parent c51d000
Malcolm Tredinnick authored July 22, 2008

Showing 1 changed file with 2 additions and 0 deletions. Show diff stats Hide diff stats

  1. 2  django/db/models/fields/__init__.py
2  django/db/models/fields/__init__.py
@@ -477,6 +477,8 @@ def formfield(self, **kwargs):
477 477
 class BooleanField(Field):
478 478
     def __init__(self, *args, **kwargs):
479 479
         kwargs['blank'] = True
  480
+        if 'default' not in kwargs and not kwargs.get('null'):
  481
+            kwargs['default'] = False
480 482
         Field.__init__(self, *args, **kwargs)
481 483
 
482 484
     def get_internal_type(self):

0 notes on commit 6ef47cf

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