Django

Code

Changeset 8050

Show
Ignore:
Timestamp:
07/21/08 23:49:32 (5 months ago)
Author:
mtredinnick
Message:

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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/db/models/fields/__init__.py

    r7977 r8050  
    478478    def __init__(self, *args, **kwargs): 
    479479        kwargs['blank'] = True 
     480        if 'default' not in kwargs and not kwargs.get('null'): 
     481            kwargs['default'] = False 
    480482        Field.__init__(self, *args, **kwargs) 
    481483