Django

Code

Changeset 8910

Show
Ignore:
Timestamp:
09/03/08 01:14:13 (4 months ago)
Author:
mtredinnick
Message:

Fixed #8802 -- Documented MySQL's usage of 1/0 instead of True/False for model
BooleanFields?.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/ref/databases.txt

    r8843 r8910  
    229229.. _AlterModelOnSyncDB: http://code.djangoproject.com/wiki/AlterModelOnSyncDB 
    230230 
     231Boolean fields in Django 
     232------------------------- 
     233 
     234Since MySQL doesn't have a direct ``BOOLEAN`` column type, Django uses a 
     235``TINYINT`` column with values of ``1`` and ``0`` to store values for the 
     236:class:`~django.db.models.BooleanField` model field. Refer to the documentation 
     237of that field for more details, but usually this won't be something that will 
     238matter unless you're printing out the field values and are expecting to see 
     239``True`` and ``False.``. 
     240 
    231241 
    232242.. _oracle-notes: 
  • django/trunk/docs/ref/models/fields.txt

    r8862 r8910  
    297297The admin represents this as a checkbox. 
    298298 
     299.. admonition:: MySQL users.. 
     300 
     301    A boolean field in MySQL is stored as a ``TINYINT`` column with a value of 
     302    either 0 or 1 (most databases have a proper ``BOOLEAN`` type instead). So, 
     303    for MySQL, only, when a ``BooleanField`` is retrieved from the database 
     304    and stored on a model attribute, it will have the values 1 or 0, rather 
     305    than ``True`` or ``False``. Normally, this shouldn't be a problem, since 
     306    Python guarantees that ``1 == True`` and ``0 == False`` are both true. 
     307    Just be careful if you're writing something like ``obj is True`` when 
     308    ``obj`` is a value from a boolean attribute on a model. If that model was 
     309    constructed using the ``mysql`` backend, the "``is``" test will fail. 
     310    Prefer an equality test (using "``==``") in cases like this. 
     311 
    299312``CharField`` 
    300313-------------