Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 973
Prakhar Rathi Avatar asked Mar 05 '26 03:03

Prakhar Rathi


1 Answers

NullBooleanField was removed in DRF 3.14.0 - see https://github.com/encode/django-rest-framework/pull/8599

Suggest to avoid 3.14.0 unless you can find another way to resolve..

djangorestframework>=3.13.1,!=3.14.0
like image 141
maharg101 Avatar answered Mar 06 '26 17:03

maharg101