Skip to main content

A simple package to handle multiple serializers for the same ViewSet in Django Rest Framework

Project description

drf-multi-serializers

A simple package to handle multiple serializers for the same ViewSet in Django Rest Framework.

Installation

pip install drf-multi-serializers

Usage

Simply import the MultiSerializerMixin and use it in your ViewSet:

from drf_multi_serializers.mixins import MultiSerializerMixin

class MyViewSet(MultiSerializerMixin, viewsets.ModelViewSet):
    ...
    serializer_classes = {
        "create": MyCreateSerializer,
        "list": MyListSerializer,
        "metadata": MyMetadataSerializer,  # create ViewSets require either serializer_class or metadata serializer for OPTION requests
        "partial_update": MyUpdateSerializer,
        "retrieve": MyRetrieveSerializer,
        "update": MyUpdateSerializer,
    }
    ...

Contributing

Contributions are welcome! To get started, please refer to our contribution guidelines.

Issues

If you encounter any problems while using this package, please open a new issue here.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drf_multi_serializers-1.0.0.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

drf_multi_serializers-1.0.0-py3-none-any.whl (3.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page