-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Conversation
d1df4cb
to
75d6ad3
Compare
LGTM 👍 |
rest_framework/fields.py
Outdated
|
||
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.' |
There was a problem hiding this comment.
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.
There was a problem hiding this 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!
The surrounding tests use unittest style assertions. Should those also be updated for consistency? |
a825a60
to
6ae709a
Compare
In that case we’re good here. Nice one! |
* Add tests for BooleanField when nullable * Allow nullable BooleanField in Django 2.1 * Drop 'BooleanField.allow_null' check * Remove conflicting false/null values
Fix #6103.