REST Framework YAML

YAML support for Django REST Framework


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


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


Install using pip...

$ pip install djangorestframework-yaml



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

from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework_yaml.parsers import YAMLParser
from rest_framework_yaml.renderers import YAMLRenderer

class ExampleView(APIView):
    A view that can accept POST requests with YAML content.
    parser_classes = (YAMLParser,)
    renderer_classes = (YAMLRenderer,)

    def post(self, request, format=None):
        return Response({'received data': request.DATA})

Sample output

  is_staff: true
  url: ""
  username: jpadilla


Install testing requirements.

$ pip install -r requirements.txt

Run with runtests.

$ ./

You can also use the excellent tox testing tool to run the tests against all supported versions of Python and Django. Install tox globally, and then simply run:

$ tox


To build the documentation, you'll need to install mkdocs.

$ pip install mkdocs

To preview the documentation:

$ mkdocs serve
Running at:

To build the documentation:

$ mkdocs build