Skip to content

Allow nullable BooleanField in Django 2.1 #6183

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

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

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

Choose a reason for hiding this comment

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

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 September 13, 2018 16:13
@tomchristie
Copy link
Member

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
@rpkilby rpkilby deleted the nullable-booleanfield branch September 13, 2018 16:44
@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.

4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy