Recursive Serialization for Django REST framework
Recursive Serialization for Django REST framework
This package provides a RecursiveField
that enables you to serialize a tree,
linked list, or even a directed acyclic graph. Also supports validation,
deserialization, ModelSerializers, and multi-step recursive structures.
from rest_framework import serializers
from rest_framework_recursive.fields import RecursiveField
class TreeSerializer(serializers.Serializer):
name = serializers.CharField()
children = serializers.ListField(child=RecursiveField())
see here for more usage examples
Install using pip
…
$ pip install djangorestframework-recursive
Install testing requirements.
$ pip install -r requirements.txt
Run with runtests.
$ ./runtests.py
You can also use the excellent tox testing tool to run the tests against all supported versions of Python and Django. Install tox globally, and then simply run:
$ tox