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/drf-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/drf-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.1.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: drf_yaml-3.0.1.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-1037-azure

File hashes

Hashes for drf_yaml-3.0.1.tar.gz
Algorithm Hash digest
SHA256 b6aa05d34f66717d9973984e6d664de76999fa088aab2b91739e2dfb0877a202
MD5 67758ec4df695c90ec70180da0063281
BLAKE2b-256 663a24e5e83ccbacab5dab91e9f64e79038fb65915859bcc7272c34584db4143

See more details on using hashes here.

File details

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

File metadata

  • Download URL: drf_yaml-3.0.1-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-1037-azure

File hashes

Hashes for drf_yaml-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0f3a0c15f5bea0c0f067c24b21789c83aa4c4b50d3ef74ad1a83007b4ad72f2f
MD5 82e63d3164b2bc15bebbc61d786138f0
BLAKE2b-256 2bb186cff9292f00f169d76688a6ef9898de08426baf8266808a32ce7c9609db

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