From 6ef47cfe5fe728bcc0290543eccd87e63c11d6a1 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Tue, 22 Jul 2008 04:49:32 +0000 Subject: [PATCH] To ensure that a model BooleanField has an explicit value set (and since 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 --- django/db/models/fields/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 78f75aea35..439633c45f 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -477,6 +477,8 @@ class AutoField(Field): 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):