7

After upgrading djangorestframework from djangorestframework==3.13.1 to djangorestframework==3.14.0 the code

from rest_framework.serializers import NullBooleanField

Throws

AttributeError: module 'rest_framework.serializers' has no attribute 'NullBooleanField'

Reading the release notes I don't see a deprecation. Where did it go?

Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
  • 2
    Aparently it is an issue in drf_spectacular: https://github.com/tfranzel/drf-spectacular/issues/816 that got fixed with `drf-spectacular==0.24.1` – Martin Thoma Sep 23 '22 at 06:39
  • 1
    I've added it to the drf project as a discussion:https://github.com/encode/django-rest-framework/discussions/8667 – Martin Thoma Sep 23 '22 at 06:48

1 Answers1

3

For what it's worth, there's a deprecation warning in the previous version, which also suggests a fix:

The NullBooleanField is deprecated and will be removed starting with 3.14. Instead use the BooleanField field and set allow_null=True which does the same thing.

djvg
  • 11,722
  • 5
  • 72
  • 103
  • Side note: Django's `NullBooleanField` is also [removed in Django 4.0](https://docs.djangoproject.com/en/4.1/releases/4.0/#features-removed-in-4-0) – djvg Oct 27 '22 at 11:32