Changeset 8910
- Timestamp:
- 09/03/08 01:14:13 (4 months ago)
- Files:
-
- django/trunk/docs/ref/databases.txt (modified) (1 diff)
- django/trunk/docs/ref/models/fields.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/docs/ref/databases.txt
r8843 r8910 229 229 .. _AlterModelOnSyncDB: http://code.djangoproject.com/wiki/AlterModelOnSyncDB 230 230 231 Boolean fields in Django 232 ------------------------- 233 234 Since 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 237 of that field for more details, but usually this won't be something that will 238 matter unless you're printing out the field values and are expecting to see 239 ``True`` and ``False.``. 240 231 241 232 242 .. _oracle-notes: django/trunk/docs/ref/models/fields.txt
r8862 r8910 297 297 The admin represents this as a checkbox. 298 298 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 299 312 ``CharField`` 300 313 -------------
