Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: In browsable API HTML forms boolean fields do not change correctly #2776

ghost opened this issue Mar 29, 2015 · 6 comments

bug: In browsable API HTML forms boolean fields do not change correctly #2776

ghost opened this issue Mar 29, 2015 · 6 comments


Copy link

ghost commented Mar 29, 2015

Hi, I am using REST framework v3.1.1 and I noticed that BooleanFields on the HTML form inside the
browsable API does not take effect and change the data as expected.

To reproduce:
Make a serializer with some boolean fields
In the browsable API's HTML form, try to edit the boolean checkbox
Compare the result returned with the expected output

Every time I have to explicitly change the values in the raw data for the expected change to occur
before the POST and PUT request is made

Copy link

ghost commented Mar 29, 2015

I have also just noticed that you can change them from false to true then it will change as expected, but once they are set to true you cannot change it to false using the HTML form.

Copy link

maryokhin commented Mar 30, 2015

I noticed the same behaviour before, but dismissed on lack of coffee.

Copy link

tomchristie commented Aug 13, 2015

This was occuring if required=False was also set in the field - so will have tended to be seen by users of automatic ModelSerializers, rather than users of Serializer. Now resolved.

Copy link

rkishore commented Sep 13, 2018

Unfortunately, I still see this issue where checking the checkbox corresponding to a BooleanField in the browsable API HTML form has no effect. The BooleanField is always set to False whether the checkbox is checked or not.

I am using

  • django-rest-framework v3.8.2
  • Django v1.11.15
  • python v2.7.6

My model in question looks as follows:

class Location(UserData):

    name = models.TextField(default='My Location 1', help_text="A label for this location.")

    input_flag = models.BooleanField(default=False, help_text="Is this a location where input files reside or where output files should be stored?")

The corresponding ModelSerializer is:

class LocationSerializer(serializers.ModelSerializer):
    class Meta:
        model = Location
        fields = ('id', 'name', 'input_flag', ...)

What other information should I provide to help replicate this issue at your end? Also, should this issue be reopened?

Copy link

piotrsynowiec commented Sep 18, 2020

The bug still is not resolved on djangorestframework v3.11.1. Changing the boolean value via RAW data works, but via html form it doesn't (you can change from False to True, but not the other way).

Copy link

xordoquy commented Sep 20, 2020

Testing with the DRF tutorial with the snippet's linenos and it works fine with the browsable api.
You'll need to write a test case similar to existing test case in order to demonstrate the issue.
Meanwhile, there's nothing we can do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

5 participants