Skip to main content
Help the Python Software Foundation raise $60,000 USD by December 31st!  Building the PSF Q4 Fundraiser

Django REST framework serializer utility

Project description

DRF multiple serializer

Build Status

Extension for using multiple serializer in Django REST Framework.


Install from PyPI

pip install drf-multiple-serializer

There is no need to modify your INSTALLED_APPS setting.


Action Base

Set the serializer to serializer_classes with the viewset action.
The rest of the actions use the default serializer.

from rest_framework import viewsets
from drf_multiple_serializer import MultipleSerializerMixin

class CategoryViewSet(ActionBaseSerializerMixin,
    queryset = Category.objects.all()
    serializer_classes = {
        'default': CategorySerializer,
        'list': CategoryListSerializer,
        'retrieve': CategoryReadSerializer,

Read & Write

Set the read & write serializer to serializer_classes.
List, Retrieve actions use a read serializer,
and the other actions (include delete) use a write serializer.

from rest_framework import viewsets
from drf_multiple_serializer import ReadWriteSerializerMixin

class ItemViewSet(ReadWriteSerializerMixin,
    queryset = Item.objects.all()
    serializer_classes = {
        'read': ItemReadSerializer,
        'write': ItemWriteSerializer,


> python3 -m venv venv
> source venv/bin/activate
(venv) > pytest

Project details

Download files

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

Files for drf-multiple-serializer, version 0.2.3
Filename, size File type Python version Upload date Hashes
Filename, size drf-multiple-serializer-0.2.3.tar.gz (3.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page