# REST Framework YAML
[![build-status-image]][github-action]
[![pypi-version]][pypi]
**YAML support for Django REST Framework**
Full documentation for the project is available at [http://jpadilla.github.io/django-rest-framework-yaml][docs].
## Overview
YAML support extracted as a third party package directly from the official Django REST Framework implementation. It's built using the [PyYAML][pyyaml] package.
## Requirements
* Python (2.7, 3.3, 3.4)
* Django (1.6, 1.7)
## Installation
Install using `pip`...
```bash
$ pip install djangorestframework-yaml
```
## Example
```python
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.
```python
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
```yaml
---
-
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][docs].
You may also want to follow the [author][jpadilla] on Twitter.
[build-status-image]: https://github.com/jpadilla/django-rest-framework-yaml/workflows/CI/badge.svg
[github-action]: https://github.com/jpadilla/django-rest-framework-yaml/actions?query=workflow%3ACI
[pypi-version]: https://img.shields.io/pypi/v/djangorestframework-yaml.svg
[pypi]: https://pypi.python.org/pypi/djangorestframework-yaml
[pyyaml]: http://pyyaml.org/
[docs]: http://jpadilla.github.io/django-rest-framework-yaml
[jpadilla]: https://twitter.com/jpadilla_
Raw data
{
"_id": null,
"home_page": "https://github.com/jpadilla/django-rest-framework-yaml",
"name": "djangorestframework-yaml",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.5",
"maintainer_email": "",
"keywords": "",
"author": "Jos\u00e9 Padilla",
"author_email": "hello@jpadilla.com",
"download_url": "https://files.pythonhosted.org/packages/61/3f/3bfebf3d0bcfd3aa448534b0631efdf74851cc8777adf327a157ae800834/djangorestframework-yaml-2.0.0.tar.gz",
"platform": "",
"description": "# REST Framework YAML\n\n[![build-status-image]][github-action]\n[![pypi-version]][pypi]\n\n**YAML support for Django REST Framework**\n\nFull documentation for the project is available at [http://jpadilla.github.io/django-rest-framework-yaml][docs].\n\n## Overview\n\nYAML support extracted as a third party package directly from the official Django REST Framework implementation. It's built using the [PyYAML][pyyaml] package.\n\n## Requirements\n\n* Python (2.7, 3.3, 3.4)\n* Django (1.6, 1.7)\n\n## Installation\n\nInstall using `pip`...\n\n```bash\n$ pip install djangorestframework-yaml\n```\n\n## Example\n\n```python\nREST_FRAMEWORK = {\n 'DEFAULT_PARSER_CLASSES': (\n 'rest_framework_yaml.parsers.YAMLParser',\n ),\n 'DEFAULT_RENDERER_CLASSES': (\n 'rest_framework_yaml.renderers.YAMLRenderer',\n ),\n}\n```\n\nYou can also set the renderer and parser used for an individual view, or viewset, using the APIView class based views.\n\n```python\nfrom rest_framework import routers, serializers, viewsets\nfrom rest_framework_yaml.parsers import YAMLParser\nfrom rest_framework_yaml.renderers import YAMLRenderer\n\n# Serializers define the API representation.\nclass UserSerializer(serializers.HyperlinkedModelSerializer):\n class Meta:\n model = User\n fields = ('url', 'username', 'email', 'is_staff')\n\n\n# ViewSets define the view behavior.\nclass UserViewSet(viewsets.ModelViewSet):\n queryset = User.objects.all()\n serializer_class = UserSerializer\n parser_classes = (YAMLParser,)\n renderer_classes = (YAMLRenderer,)\n```\n\n### Sample output\n\n```yaml\n---\n-\n email: jpadilla@example.com\n is_staff: true\n url: \"http://127.0.0.1:8000/users/1/\"\n username: jpadilla\n```\n\n## Documentation & Support\n\nFull documentation for the project is available at [http://jpadilla.github.io/django-rest-framework-yaml][docs].\n\nYou may also want to follow the [author][jpadilla] on Twitter.\n\n\n[build-status-image]: https://github.com/jpadilla/django-rest-framework-yaml/workflows/CI/badge.svg\n[github-action]: https://github.com/jpadilla/django-rest-framework-yaml/actions?query=workflow%3ACI\n[pypi-version]: https://img.shields.io/pypi/v/djangorestframework-yaml.svg\n[pypi]: https://pypi.python.org/pypi/djangorestframework-yaml\n[pyyaml]: http://pyyaml.org/\n[docs]: http://jpadilla.github.io/django-rest-framework-yaml\n[jpadilla]: https://twitter.com/jpadilla_\n\n\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "YAML support for Django REST Framework",
"version": "2.0.0",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c1d8033eae74851b5c8894a5a35fb5bb3ec6d45714f3183962dbce5a2b17f18f",
"md5": "a867eac1249419da7fb8ab7044d881aa",
"sha256": "7fe744e6004d2191fa1cb8a4fc62f98150202bfebd60702a04f8187cc240b7c4"
},
"downloads": -1,
"filename": "djangorestframework_yaml-2.0.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "a867eac1249419da7fb8ab7044d881aa",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.5",
"size": 6684,
"upload_time": "2020-04-27T01:19:29",
"upload_time_iso_8601": "2020-04-27T01:19:29.990044Z",
"url": "https://files.pythonhosted.org/packages/c1/d8/033eae74851b5c8894a5a35fb5bb3ec6d45714f3183962dbce5a2b17f18f/djangorestframework_yaml-2.0.0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "613f3bfebf3d0bcfd3aa448534b0631efdf74851cc8777adf327a157ae800834",
"md5": "f0ff5bb3af5b198ccbb51bcf0f390f73",
"sha256": "1b2cfd7482425f3c6924a8eb803d6f73276e76b03293cd7144c755753e029f15"
},
"downloads": -1,
"filename": "djangorestframework-yaml-2.0.0.tar.gz",
"has_sig": false,
"md5_digest": "f0ff5bb3af5b198ccbb51bcf0f390f73",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.5",
"size": 5671,
"upload_time": "2020-04-27T01:19:31",
"upload_time_iso_8601": "2020-04-27T01:19:31.060926Z",
"url": "https://files.pythonhosted.org/packages/61/3f/3bfebf3d0bcfd3aa448534b0631efdf74851cc8777adf327a157ae800834/djangorestframework-yaml-2.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2020-04-27 01:19:31",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "jpadilla",
"github_project": "django-rest-framework-yaml",
"travis_ci": true,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "Django",
"specs": [
[
">=",
"1.6"
]
]
},
{
"name": "djangorestframework",
"specs": [
[
">=",
"2.4.3"
]
]
},
{
"name": "pytest-django",
"specs": [
[
"==",
"2.6"
]
]
},
{
"name": "pytest",
"specs": [
[
"==",
"2.5.2"
]
]
},
{
"name": "pytest-cov",
"specs": [
[
"==",
"1.6"
]
]
},
{
"name": "flake8",
"specs": [
[
"==",
"2.2.2"
]
]
},
{
"name": "wheel",
"specs": [
[
"==",
"0.24.0"
]
]
},
{
"name": "mkdocs",
"specs": [
[
"==",
"0.11.1"
]
]
}
],
"tox": true,
"lcname": "djangorestframework-yaml"
}