Remove special case for mapping NullBooleanField

In newer versions of Django, the `NullBooleanField` is handled the
same way as a `BooleanField(null=True)`. Given that we also support
that combination, and that our own `NullBooleanField` behaves in the
same manner, it makes sense to remove the special casing that exists
for it.
This commit is contained in:
Kevin Brown 2020-01-07 19:33:35 -05:00
parent a07a71a8f5
commit 1cc79a34e0
2 changed files with 1 additions and 4 deletions

View File

@ -868,7 +868,7 @@ class ModelSerializer(Serializer):
models.FloatField: FloatField, models.FloatField: FloatField,
models.ImageField: ImageField, models.ImageField: ImageField,
models.IntegerField: IntegerField, models.IntegerField: IntegerField,
models.NullBooleanField: NullBooleanField, models.NullBooleanField: BooleanField,
models.PositiveIntegerField: IntegerField, models.PositiveIntegerField: IntegerField,
models.PositiveSmallIntegerField: IntegerField, models.PositiveSmallIntegerField: IntegerField,
models.SlugField: SlugField, models.SlugField: SlugField,

View File

@ -104,9 +104,6 @@ def get_field_kwargs(field_name, model_field):
if model_field.has_default() or model_field.blank or model_field.null: if model_field.has_default() or model_field.blank or model_field.null:
kwargs['required'] = False kwargs['required'] = False
if model_field.null and not isinstance(model_field, models.NullBooleanField):
kwargs['allow_null'] = True
if model_field.blank and (isinstance(model_field, (models.CharField, models.TextField))): if model_field.blank and (isinstance(model_field, (models.CharField, models.TextField))):
kwargs['allow_blank'] = True kwargs['allow_blank'] = True