Last active
December 1, 2018 21:35
-
-
Save dz0/1145541c956389a4a7c07647cac760b7 to your computer and use it in GitHub Desktop.
DRF validate None on BooleanField serialization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from rest_framework.serializers import Serializer, BooleanField | |
| # BooleanField.FALSE_VALUES.add(None) # does not help | |
| class S(Serializer): | |
| bf = BooleanField(required=False, read_only=True) | |
| class example: | |
| bf = None # I expect it to become **False** | |
| s = S(instance=example) | |
| assert s.data['bf'] == False # Fails, because {'bf': None} | |
| # seems like related https://github.com/encode/django-rest-framework/issues/2299 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment