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:
Kumi 2024-05-07 16:19:30 +02:00
parent 2aa568769d
commit cfe54415c7
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -128,6 +128,12 @@ class CategoryDeleteView(LoginRequiredMixin, TitleMixin, DeleteView):
class FileUploadView(LoginRequiredMixin, GenericAPIView):
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):
return MediaUploadView.as_view()(request)