Skip to main content

django-toon is a package for sending data in the Toon format

Project description

language: Farsi -- Arabic

django-toon is a package for sending data in the Toon format, which is several times faster than JSON.

The library offers two important features for Django. For example, you can create dynamic views that can return either JSON or Toon based on the request.

django-toon — Django Integration Guide

Usage:

Installation

pip install "django-toon"

Return Toon for all requests

settings.py

REST_FRAMEWORK = {
    'DEFAULT_RENDERER_CLASSES': [
        'django_toon.django.render.ToonRenderer',
    ],
    'DEFAULT_PARSER_CLASSES': [
        'django_toon.django.parser.ToonParser',
    ],
}

Enable dynamic mode (JSON or Toon based on headers)

REST_FRAMEWORK = {
    'DEFAULT_RENDERER_CLASSES': [
         'django_toon.django.render.DynamicRenderer',
    ],
    'DEFAULT_PARSER_CLASSES': [
        'django_toon.django.parser.DynamicParser',
    ],
}

Header Examples

Send JSON → Receive Toon:

Content-Type: application/json
Accept: application/x-toon

Send Toon → Receive Toon:

Content-Type: application/x-toon
Accept: application/x-toon

Send Toon → Receive JSON:

Content-Type: application/x-toon
Accept: application/json

Per-View Configuration

Dynamic view

views.py

from django_toon.parser import DynamicParser
from django_toon.render import DynamicRenderer

class Index(APIView):
    parser_classes = [DynamicParser]
    renderer_classes = [DynamicRenderer]

    def get(self, request, *args, **kwargs):
        return Response({"message": "Hello django-toon"})

Toon-only view

from django_toon.parser import ToonParser
from django_toon.render import ToonRenderer

class Index(APIView):
    parser_classes = [ToonParser]
    renderer_classes = [ToonRenderer]

    def get(self, request, *args, **kwargs):
        return Response({"message": "Hello django-toon"})

How to Test API:

source .venv/bin/activate
$ django-toon version

> 0.1.1

you can use GET and POST method to test your api

$ django-toon get https://exmaple.com/
$ django-toon post https://exmaple.com/ --payload '{"key": "value"}'

Contributing

We warmly welcome all contributions to django-toon! Whether you have an idea for improvement, found a bug, or want to add a new feature, we would be happy to have your help.

How to contribute

For small changes, feel free to open a Pull Request directly.

For larger features or significant changes, please open an Issue first so we can discuss the approach together.

Make sure your code is clean, readable, and includes any necessary tests.

🐞 Reporting Issues

If you encounter a problem:

First check whether the issue has already been reported.

If not, please open a New Issue with:

A clear description of the problem

Steps to reproduce

Python/framework/OS versions

Any relevant logs or error messages

We do our best to respond and fix issues as quickly as possible.

django-toonLicense (MIT-based Open License)

Copyright (c) 2025 django-toon Developers

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

This project is completely free and open-source.
There are no costs, no licensing fees, no subscription requirements, and
you are free to use it in personal, educational, and commercial projects.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_toon-0.1.1.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_toon-0.1.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file django_toon-0.1.1.tar.gz.

File metadata

  • Download URL: django_toon-0.1.1.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for django_toon-0.1.1.tar.gz
Algorithm Hash digest
SHA256 61bf021033ec744704df71812a0471d10b7e7729b36694b6984053d8df5ea9c4
MD5 0155be9cc93ab4b2c11ac1fe12cac51e
BLAKE2b-256 fdf15eb692647058c582697dbd2aed4b72a7134aaaef9c69f6ba57314c9db331

See more details on using hashes here.

File details

Details for the file django_toon-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: django_toon-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for django_toon-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c5d0a79a92431dceb383435c8fcd626633e45d9d6e1328d5dcd9bd3c3c607d26
MD5 7d9f517c40a301bea8d3c8c71e61e522
BLAKE2b-256 0d77ecc2dc71e59bfd16ee2941be75cc61e2ecc70a195cec30060a83bc620712

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page