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

Allow nullable BooleanField in Django 2.1 #6183

Merged
merged 4 commits into from Sep 13, 2018

Conversation

rpkilby
Copy link
Member

@rpkilby rpkilby commented Sep 13, 2018

Fix #6103.

@iMerica
Copy link

iMerica commented Sep 13, 2018

LGTM 👍

@encode encode deleted a comment from codecov-io Sep 13, 2018

def __init__(self, **kwargs):
assert 'allow_null' not in kwargs, '`allow_null` is not a valid option. Use `NullBooleanField` instead.'
if django.VERSION < (2, 1):
assert 'allow_null' not in kwargs, '`allow_null` is not a valid option. Use `NullBooleanField` instead.'
Copy link
Member

@tomchristie tomchristie Sep 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can actually support this for all Django versions for the serializer field, it's just that the model would need to use a models.NullBooleanField.

Ie. I think we can just drop the check completely.

Copy link
Member

@tomchristie tomchristie left a comment

Great stuff, thanks!

Let's drop the "assert 'allow_null' not in kwargs" check, and use pytest style assertions. After that I think we're good to go!

@rpkilby
Copy link
Member Author

rpkilby commented Sep 13, 2018

and use pytest style assertions

The surrounding tests use unittest style assertions. Should those also be updated for consistency?

@rpkilby rpkilby force-pushed the nullable-booleanfield branch from a825a60 to 6ae709a Compare Sep 13, 2018
@tomchristie
Copy link
Member

tomchristie commented Sep 13, 2018

The surrounding tests use unittest style assertions.

In that case we’re good here. Nice one!

@tomchristie tomchristie merged commit fc6cbb5 into encode:master Sep 13, 2018
1 check passed
@rpkilby rpkilby deleted the nullable-booleanfield branch Sep 13, 2018
@encode encode deleted a comment from codecov-io Sep 13, 2018
pchiquet pushed a commit to pchiquet/django-rest-framework that referenced this pull request Nov 17, 2020
* Add tests for BooleanField when nullable

* Allow nullable BooleanField in Django 2.1

* Drop 'BooleanField.allow_null' check

* Remove conflicting false/null values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants