Library of useful Rest Framework serializers for django
Many-to-many serializer that will loop through an infinite depth and create, update and delete related entities.
Installation
pip install git+https://github.com/AccentDesign/Accent_RestSerializers.git@master#egg=rest_serializerssettings.py
INSTALLED_APPS = [
...
'rest_serializers',
...
]This class is required in the parent serializer.
Example
from rest_serializers.serializers import ManyToManySerializer
class ChildSerializer(serializers.ModelSerializer):
class Meta:
model = Child
fields = ('id', 'name')
class ParentSerializer(ManyToManySerializer):
children = ChildSerializer(many=True)
class Meta:
model = Parent
fields = ('id', 'name', 'children')Here the ChildSerializer can also inherit from ManyToManySerializer to include a further depth and so on.
uv sync --all-extrasuv run tests/manage.py testblack:
uv run black rest_serializers testsruff:
uv run ruff check --fix rest_serializers testsinstall dependencies:
uv tool install hatchbuild package:
rm -rf dist && uv builduv publish --token <token>