Serialize a partial subset of fields in the API
Project description
Installation
pip install djangorestframework-queryfields
Quickstart
Specify your base model serializer like this:
from rest_framework.serializers import ModelSerializer
from drf_queryfields import QueryFieldsMixin
class MyModelSerializer(QueryFieldsMixin, ModelSerializer):
pass
Usage
GET http://127.0.0.1:8000/snippets/
HTTP/1.1 200 OK
...
[
{
"id": 1,
"title": "",
"code": "foo = \"bar\"\n",
"linenos": false,
"language": "python",
"style": "friendly"
},
{
"id": 2,
"title": "",
"code": "print \"hello, world\"\n",
"linenos": false,
"language": "python",
"style": "friendly"
}
]
GET http://127.0.0.1:8000/snippets/?fields=id,code
HTTP/1.1 200 OK
...
[
{
"id": 1,
"code": "foo = \"bar\"\n",
},
{
"id": 2,
"code": "print \"hello, world\"\n",
}
]
GET http://127.0.0.1:8000/snippets/?fields!=code
HTTP/1.1 200 OK
...
[
{
"id": 1,
"title": "",
"linenos": false,
"language": "python",
"style": "friendly"
},
{
"id": 2,
"title": "",
"linenos": false,
"language": "python",
"style": "friendly"
}
]
Feedback
For feature requests or bug reports, please create an issue here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for djangorestframework-queryfields-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c1d61404e1308158b2a360f0913aed5b5a60f66ee3239345b12f5e1f1458947 |
|
MD5 | 419cd86f811469dd8f963859d684c022 |
|
BLAKE2b-256 | f62984932d576174aaee18f6430a1b2730c1117c38b2429793dc3bf07ea4ac00 |
Close
Hashes for djangorestframework_queryfields-1.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f10fb59d3364b527c8df7f10d69d0c51745610bbd5dd00b6374357bf449f7980 |
|
MD5 | d47ce88442340e2af96f09f1d8ad1756 |
|
BLAKE2b-256 | 805ba578ca2a3781214039bc458f11ad20ed6b652fa68a77d87b7aefc05e0923 |