# REST Framework YAML
![build-status-image]
[![pypi-version]][pypi]
**YAML support for Django REST Framework**
Full documentation for the project is available at [http://qu4tro.github.io/drf-yaml][docs].
## Overview
YAML support for the Django REST Framework, forked from [https://github.com/jpadilla/django-rest-framework-yaml][original].
## Requirements
* Python (3.8, 3.9, 3.10, 3.11)
* Django (3.2, 4.*)
## Installation
Install using `pip`...
```bash
$ pip install drf-yaml
```
## Example
```python
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.
```python
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
```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://qu4tro.github.io/drf-yaml][docs].
[build-status-image]: https://img.shields.io/github/checks-status/Qu4tro/drf-yaml/main
[pypi-version]: https://img.shields.io/pypi/v/drf-yaml.svg
[pypi]: https://pypi.python.org/pypi/drf-yaml
[docs]: http://qu4tro.github.io/drf-yaml
[original]: https://github.com/jpadilla/django-rest-framework-yaml
Raw data
{
"_id": null,
"home_page": "https://github.com/Qu4tro/drf-yaml",
"name": "drf-yaml",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Jos\u00e9 Padilla",
"author_email": "hello@jpadilla.com",
"download_url": "https://files.pythonhosted.org/packages/66/3a/24e5e83ccbacab5dab91e9f64e79038fb65915859bcc7272c34584db4143/drf_yaml-3.0.1.tar.gz",
"platform": null,
"description": "# REST Framework YAML\n\n![build-status-image]\n[![pypi-version]][pypi]\n\n**YAML support for Django REST Framework**\n\nFull documentation for the project is available at [http://qu4tro.github.io/drf-yaml][docs].\n\n## Overview\n\nYAML support for the Django REST Framework, forked from [https://github.com/jpadilla/django-rest-framework-yaml][original].\n\n## Requirements\n\n* Python (3.8, 3.9, 3.10, 3.11)\n* Django (3.2, 4.*)\n\n## Installation\n\nInstall using `pip`...\n\n```bash\n$ pip install drf-yaml\n```\n\n## Example\n\n```python\nREST_FRAMEWORK = {\n 'DEFAULT_PARSER_CLASSES': (\n 'drf_yaml.parsers.YAMLParser',\n ),\n 'DEFAULT_RENDERER_CLASSES': (\n 'drf_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 drf_yaml.parsers import YAMLParser\nfrom drf_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://qu4tro.github.io/drf-yaml][docs].\n\n\n[build-status-image]: https://img.shields.io/github/checks-status/Qu4tro/drf-yaml/main\n[pypi-version]: https://img.shields.io/pypi/v/drf-yaml.svg\n[pypi]: https://pypi.python.org/pypi/drf-yaml\n[docs]: http://qu4tro.github.io/drf-yaml\n[original]: https://github.com/jpadilla/django-rest-framework-yaml\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "YAML support for Django REST Framework",
"version": "3.0.1",
"project_urls": {
"Homepage": "https://github.com/Qu4tro/drf-yaml"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2bb186cff9292f00f169d76688a6ef9898de08426baf8266808a32ce7c9609db",
"md5": "82e63d3164b2bc15bebbc61d786138f0",
"sha256": "0f3a0c15f5bea0c0f067c24b21789c83aa4c4b50d3ef74ad1a83007b4ad72f2f"
},
"downloads": -1,
"filename": "drf_yaml-3.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "82e63d3164b2bc15bebbc61d786138f0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 6559,
"upload_time": "2023-06-02T06:37:13",
"upload_time_iso_8601": "2023-06-02T06:37:13.056529Z",
"url": "https://files.pythonhosted.org/packages/2b/b1/86cff9292f00f169d76688a6ef9898de08426baf8266808a32ce7c9609db/drf_yaml-3.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "663a24e5e83ccbacab5dab91e9f64e79038fb65915859bcc7272c34584db4143",
"md5": "67758ec4df695c90ec70180da0063281",
"sha256": "b6aa05d34f66717d9973984e6d664de76999fa088aab2b91739e2dfb0877a202"
},
"downloads": -1,
"filename": "drf_yaml-3.0.1.tar.gz",
"has_sig": false,
"md5_digest": "67758ec4df695c90ec70180da0063281",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 5468,
"upload_time": "2023-06-02T06:37:14",
"upload_time_iso_8601": "2023-06-02T06:37:14.568216Z",
"url": "https://files.pythonhosted.org/packages/66/3a/24e5e83ccbacab5dab91e9f64e79038fb65915859bcc7272c34584db4143/drf_yaml-3.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-02 06:37:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Qu4tro",
"github_project": "drf-yaml",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "drf-yaml"
}