Skip to main content

Django REST framework serializer utility

Project description

DRF multiple serializer

Extension for using multiple serializer in Django REST Framework.

Installation

Install from PyPI

pip install drf-multiple-serializer

There is no need to modify your INSTALLED_APPS setting.

Usage

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

from .models import Category, Item


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


class ItemViewSet(MultipleSerializerMixin,
                  viewsets.ModelViewSet):
    queryset = Item.objects.all()
    serializer_classes = {
        'default': ItemSerializer,
        'create': ItemWriteSerializer,
    }

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-multiple-serializer-0.1.1.tar.gz (2.0 kB view details)

Uploaded Source

File details

Details for the file drf-multiple-serializer-0.1.1.tar.gz.

File metadata

  • Download URL: drf-multiple-serializer-0.1.1.tar.gz
  • Upload date:
  • Size: 2.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.9.1 tqdm/4.26.0 CPython/3.6.8

File hashes

Hashes for drf-multiple-serializer-0.1.1.tar.gz
Algorithm Hash digest
SHA256 061c3c5abbccc404f4a758c8f022a22731b3fff5f5d733b07f439bb3b22d4e8c
MD5 22cc05464cc309f618652aa21b7da3d2
BLAKE2b-256 a785bcec9948d2f505c253f31d2721dca9d32a6ec4bdda1fe4d4eefef74253bb

See more details on using hashes here.

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