REST Framework YAML
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)
| File | Size | Uploaded | |
|---|---|---|---|
| djangorestframework-yaml-2.0.0.tar.gz | 5.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|