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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for drf-multiple-serializer-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 061c3c5abbccc404f4a758c8f022a22731b3fff5f5d733b07f439bb3b22d4e8c |
|
MD5 | 22cc05464cc309f618652aa21b7da3d2 |
|
BLAKE2b-256 | a785bcec9948d2f505c253f31d2721dca9d32a6ec4bdda1fe4d4eefef74253bb |