drf-spectacular
drf-spectacular copied to clipboard
Error: Missing Serializer Class in Custom Destroy View
Description:
I encountered an error while using a custom class that extends generics.DestroyAPIView
. The error message is as follows:
/usr/local/lib/python3.8/site-packages/betik_app_person/views/relation_ship_type.py: Error: exception raised while getting serializer. Hint: Is get_serializer_class() returning None or is get_queryset() not working without a request? Ignoring the view for now. (Exception: 'CustomDestroyView' should either include a `serializer_class` attribute, or override the `get_serializer_class()` method.)
Expected Behavior:
In general, a view extending DestroyAPIView
should not require a serializer. The primary function of DestroyAPIView
is to handle DELETE requests, and it is expected that the deletion operation can be performed without needing a serializer class for validation or serialization of input data.
Current Behavior:
Despite this expectation, the error indicates that the custom destroy view is missing a serializer_class
attribute or is not properly implementing the get_serializer_class()
method. This requirement seems contradictory to the expected functionality of DestroyAPIView
.
Questions:
- Why does this custom view, which extends
DestroyAPIView
, require a serializer class? - Is there a specific condition or configuration in the Django REST Framework that mandates a serializer for delete operations, even when input validation or data serialization is not necessary?
Additional Context:
- Django REST Framework version: [insert your DRF version]
- Any relevant code snippets or configurations that may help in diagnosing the issue.
Thank you for your assistance!