Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Missing Serializer Class in Custom Destroy View #1314

Open
lidyum opened this issue Oct 16, 2024 · 0 comments
Open

Error: Missing Serializer Class in Custom Destroy View #1314

lidyum opened this issue Oct 16, 2024 · 0 comments

Comments

@lidyum
Copy link

lidyum commented Oct 16, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant