Skip to main content

REST Framework YAML

build-status-image pypi-version

YAML support for Django REST Framework

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

Overview

YAML support extracted as a third party package directly from the official Django REST Framework implementation. It's built using the PyYAML package.

Requirements

  • Python (2.7, 3.3, 3.4)
  • Django (1.6, 1.7)

Installation

Install using pip...

$ pip install djangorestframework-yaml

Example

REST_FRAMEWORK = {
    'DEFAULT_PARSER_CLASSES': (
        'rest_framework_yaml.parsers.YAMLParser',
    ),
    'DEFAULT_RENDERER_CLASSES': (
        'rest_framework_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 rest_framework_yaml.parsers import YAMLParser
from rest_framework_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://jpadilla.github.io/django-rest-framework-yaml.

You may also want to follow the author on Twitter.

Metadata

Release files for djangorestframework-yaml 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for djangorestframework-yaml 2.0.0
File Size Uploaded
djangorestframework-yaml-2.0.0.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for djangorestframework-yaml 2.0.0
File Interpreter ABI Platform
djangorestframework_yaml-2.0.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 12.4 kB

Release files / djangorestframework-yaml-2.0.0.tar.gz

Download URL djangorestframework-yaml-2.0.0.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1b2cfd7482425f3c6924a8eb803d6f73276e76b03293cd7144c755753e029f15
BLAKE2b-256 checksum
How to use checksums
613f3bfebf3d0bcfd3aa448534b0631efdf74851cc8777adf327a157ae800834
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

Release files / djangorestframework_yaml-2.0.0-py2.py3-none-any.whl

Download URL djangorestframework_yaml-2.0.0-py2.py3-none-any.whl
Size 6.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
7fe744e6004d2191fa1cb8a4fc62f98150202bfebd60702a04f8187cc240b7c4
BLAKE2b-256 checksum
How to use checksums
c1d8033eae74851b5c8894a5a35fb5bb3ec6d45714f3183962dbce5a2b17f18f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page