Skip to main content

YAML support for Django REST Framework

Project description

REST Framework YAML

build-status-image pypi-version

YAML support for Django REST Framework

Full documentation for the project is available at http://qu4tro.github.io/django-rest-framework-yaml.

Overview

YAML support for the Django REST Framework, forked from https://github.com/jpadilla/django-rest-framework-yaml.

Requirements

  • Python (3.8, 3.9, 3.10, 3.11)
  • Django (3.2, 4.*)

Installation

Install using pip...

$ pip install drf-yaml

Example

REST_FRAMEWORK = {
    'DEFAULT_PARSER_CLASSES': (
        'drf_yaml.parsers.YAMLParser',
    ),
    'DEFAULT_RENDERER_CLASSES': (
        'drf_yaml.renderers.YAMLRenderer',
    ),
}

You can also set the renderer and parser used for an individual view, or viewset, using the APIView class based views.

from rest_framework import routers, serializers, viewsets
from drf_yaml.parsers import YAMLParser
from drf_yaml.renderers import YAMLRenderer

# Serializers define the API representation.
class UserSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = User
        fields = ('url', 'username', 'email', 'is_staff')


# ViewSets define the view behavior.
class UserViewSet(viewsets.ModelViewSet):
    queryset = User.objects.all()
    serializer_class = UserSerializer
    parser_classes = (YAMLParser,)
    renderer_classes = (YAMLRenderer,)

Sample output

---
-
  email: jpadilla@example.com
  is_staff: true
  url: "http://127.0.0.1:8000/users/1/"
  username: jpadilla

Documentation & Support

Full documentation for the project is available at http://qu4tro.github.io/django-rest-framework-yaml.

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

drf_yaml-3.0.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

drf_yaml-3.0.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file drf_yaml-3.0.0.tar.gz.

File metadata

  • Download URL: drf_yaml-3.0.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.3 Linux/5.15.0-1038-azure

File hashes

Hashes for drf_yaml-3.0.0.tar.gz
Algorithm Hash digest
SHA256 eed54e925bd1b5a044d96ac3c0ec420aa8350aed4deebf162f2cfbbbe74aa6a3
MD5 5a18f26ab9cbf39f1d6c533b52989f33
BLAKE2b-256 2886b5a92ed47d24e39e65e7a21ef3c6bcea1bc388f40ba1cf282689b9933520

See more details on using hashes here.

File details

Details for the file drf_yaml-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: drf_yaml-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.3 Linux/5.15.0-1038-azure

File hashes

Hashes for drf_yaml-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 65ceced309e3a88c42a179da802f29218c00722743bd64d69a1b4ac72f4b8700
MD5 924d9824612f766c68ea46cc5256249d
BLAKE2b-256 5d593864f7cceebda72bc4833ccd1baec635f381367f37450bc18415499c18bd

See more details on using hashes here.

Supported by

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