djangoswaggerdjango-serializer

AttributeError: module 'rest_framework.serializers' has no attribute 'NullBooleanField' in Django inside Swagger


This error is thrown in django even though it's not even imported anywhere. It's thrown by OpenAPISchemaGenerator as follows:

 File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/drf_yasg/inspectors/field.py", line 406, in <module>
    (serializers.NullBooleanField, (openapi.TYPE_BOOLEAN, None)),
AttributeError: module 'rest_framework.serializers' has no attribute 'NullBooleanField'

How do I fix this? link. It doesn't answer the question.


Solution

  • The support for NullBooleanField was removed in 3.14.0. I have raised an issue on the drf-yasg github asking for support for this version of drf. They have also released a PR for this which is yet to be merged.