toon-django
Django integration for the Token-Oriented Object Notation (TOON) format. Provides a ToonResponse for plain Django views and parsers/renderers for Django REST Framework, Django Ninja, and Django Modern REST, so you can accept and emit text/toon alongside your existing content types with minimal setup.
Installation
The base package works with plain Django out of the box:
pip install toon-django
Install optional extras for the frameworks you use:
# Django Modern REST
pip install "toon-django[dmr]"
# Django Ninja
pip install "toon-django[ninja]"
# Django REST Framework
pip install "toon-django[drf]"
Usage
Plain Django
Use ToonResponse in any view the same way you would use JsonResponse:
from toon_django.http import ToonResponse
def my_view(request):
return ToonResponse({"hello": "world"})
Pass safe=False to serialize non-dict objects such as lists:
def my_list_view(request):
return ToonResponse([1, 2, 3], safe=False)
Django Modern REST
Register ToonParser and ToonRenderer on a controller:
from dmr.controller import Controller
from toon_django.contrib.dmr import ToonParser, ToonRenderer
class MyController(Controller):
parsers = [ToonParser()]
renderers = [ToonRenderer()]
Django Ninja
Pass ToonParser and ToonRenderer to the NinjaAPI constructor:
from ninja import NinjaAPI
from toon_django.contrib.ninja import ToonParser, ToonRenderer
api = NinjaAPI(parser=ToonParser(), renderer=ToonRenderer())
The API will then accept and emit Content-Type: text/toon.
Django REST Framework
Register ToonParser and ToonRenderer on a view or viewset:
from rest_framework.viewsets import ModelViewSet
from toon_django.contrib.rest_framework import ToonParser, ToonRenderer
class MyViewSet(ModelViewSet):
parser_classes = [ToonParser]
renderer_classes = [ToonRenderer]
The parser accepts Content-Type: text/toon requests; the renderer responds to Accept: text/toon.
You can also set them globally in settings.py:
REST_FRAMEWORK = {
"DEFAULT_PARSER_CLASSES": [
"toon_django.contrib.rest_framework.ToonParser",
"rest_framework.parsers.JSONParser",
],
"DEFAULT_RENDERER_CLASSES": [
"toon_django.contrib.rest_framework.ToonRenderer",
"rest_framework.renderers.JSONRenderer",
],
}
License
toon-django is distributed under the terms of the MIT license.
Metadata
Release files for toon-django 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| toon_django-0.1.0.tar.gz | 14.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| toon_django-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.7 kB
Release files / toon_django-0.1.0.tar.gz
| Download URL | toon_django-0.1.0.tar.gz |
|---|---|
| Size | 14.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ffd6702a74c0677732d3a06a0d928b4e9f94d1eb3af030bfe222f61703f289f1
|
|
BLAKE2b-256 checksum How to use checksums |
999eedc33b5ae0009f71e30247776277fd7340af40e5104641eb0521a76de8b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.
Transparency logRelease files / toon_django-0.1.0-py3-none-any.whl
| Download URL | toon_django-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aa2c72c6de5bc9502ad41bb1303223dbbf57d41e9b49560f0cfcef88972722fe
|
|
BLAKE2b-256 checksum How to use checksums |
6697edc6d6a68c26e1376eea0fd0a68e8a646587a2596f4c9110de25584f180b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.
Transparency log