#23216 closed Bug (worksforme)
CheckboxInput does not work properly with value "0"
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | Forms | Version: | 1.6 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
I loaded data to my local sqlite database from mysql database using modified mysqldump script. All boolean fields are now stored with "0" and "1" instead of "True" and "False" - sqlite datatype is tinyint instead of bool, which is not present in mysql.
Now checkboxes are always checked because of this function which does not work with 0 and 1
django.forms.widgets.py:457
def boolean_check(v):
return not (v is False or v is None or v == '')
Also BooleanField.to_python() method is not called (which would properly convert this value to Boolean), only Field.prepare_value which does nothing
Because of this bug all users seem to be superusers in django admin.
Attachments (2)
Change History (4)
comment:1 by , 11 years ago
| Resolution: | → worksforme |
|---|---|
| Status: | new → closed |
comment:2 by , 11 years ago
It works ok when is_superuser column has type bool. After my import it has type tinyint(1) and is not working. Both column types are visible as 0 and 1 in SQLite Manager. I suspect that SQLite driver in python is making automatic conversion to True and False for bool column type.
I understand that tinyint(1) is not a typical column type for BooleanField and that is the cause of this problem. I will attach screenshots that visualize this situation (is_superuser column has type changed to tinyint(1) by SQLite Manager)
by , 11 years ago
| Attachment: | tinyint_superuser2.png added |
|---|
I see values of 0 and 1 in the
auth_usertable of my SQLite database and there is no problem so I suspect the bug is not in Django.