feat(users): Add get_serializer_class to FileUploadView
Introduced a `get_serializer_class` method in the `FileUploadView` class to avoid warnings about the missing `serializer_class` attribute. This change ensures better code clarity and suppresses unnecessary warning messages during runtime, without altering the dynamic serializer class resolution based on the `media_type` in the request data. This adjustment provides a cleaner, more maintainable codebase and enhances developer experience by clearly communicating the intentional dynamic behavior of serializer class selection.
This commit is contained in:
parent
2aa568769d
commit
cfe54415c7
|
@ -128,6 +128,12 @@ class CategoryDeleteView(LoginRequiredMixin, TitleMixin, DeleteView):
|
||||||
class FileUploadView(LoginRequiredMixin, GenericAPIView):
|
class FileUploadView(LoginRequiredMixin, GenericAPIView):
|
||||||
parser_classes = (MultiPartParser, FormParser)
|
parser_classes = (MultiPartParser, FormParser)
|
||||||
|
|
||||||
|
def get_serializer_class(self):
|
||||||
|
"""This method is really only used to silence the warning about not
|
||||||
|
having a serializer_class attribute. The actual serializer class is
|
||||||
|
determined by the media_type in the request data."""
|
||||||
|
return OriginalImageSerializer
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
return MediaUploadView.as_view()(request)
|
return MediaUploadView.as_view()(request)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue