Skip to content

AccentDesign/Accent_RestSerializers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Accent_RestSerializers

Testing workflow

Description

Library of useful Rest Framework serializers for django

Includes

Many-to-many serializer that will loop through an infinite depth and create, update and delete related entities.

Getting Started

Installation

pip install git+https://github.com/AccentDesign/Accent_RestSerializers.git@master#egg=rest_serializers

settings.py

INSTALLED_APPS = [
   ...
   'rest_serializers',
   ...
]

Usage

ManyToManySerializer

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.

Install dependencies

uv sync --all-extras

Run tests

uv run tests/manage.py test

Run linters

black:

uv run black rest_serializers tests

ruff:

uv run ruff check --fix rest_serializers tests

Build package

install dependencies:

uv tool install hatch

build package:

rm -rf dist && uv build

Publish package

uv publish --token <token>

About

Generic serializers for rest framework

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages