Hello,

I've changed my database from postgresql to mysql. I have never used mysql in django projects before, so it was surprising to me when i saw 0/1 values instead of True/False in boolean fields. It wasn't an issue until i upgraded django from 1.3.1 to 1.4b. After that, all boolean fields in admin interface are checked (in edit mode). They are rendered as:

<input type="checkbox" id="id_checkbox_filter" value="0" name="checkbox_filter" checked="checked">

i've looked into forms.widgets.CheckboxInput in both django versions and noticed some logic changes when checking value:

(1.3.1)

    def __init__(self, attrs=None, check_test=bool):
        super(CheckboxInput, self).__init__(attrs)
        # check_test is a callable that takes a value and returns True
        # if the checkbox should be checked for that value.
        self.check_test = check_test

(1.4b)


    def __init__(self, attrs=None, check_test=None):
        super(CheckboxInput, self).__init__(attrs)
        # check_test is a callable that takes a value and returns True
        # if the checkbox should be checked for that value.
        if check_test is None:
self.check_test = lambda v: not (v is False or v is None or v == '')
        else:
            self.check_test = check_test

in this case "0" is treated as True.

Is this a bug?

regards,
tomasz kloc



--
You received this message because you are subscribed to the Google Groups "Django 
developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to