Skip to main content

Restrict fields returned by DRF serializers

Project description

https://img.shields.io/pypi/v/drf_restricted_fields.svg https://github.com/tj-django/drf-restricted-fields/actions/workflows/test.yml/badge.svg Documentation Status Updates

Features

Restrict fields returned by DRF serializers using the only query parameter

GET http://127.0.0.1:8000/api/users/?only=id&only=name

Serialize only the id and name fields.

{
    "count": 198,
    "next": "http://127.0.0.1:8000/api/users/?only=id&only=name&page=1",
    "previous": null,
    "results":[
        {
            "id": 1,
            "name": "Test"
        },
        ...
    ],
}

Defer fields returned by DRF serializers using the defer query parameter

GET http://127.0.0.1:8000/api/users/?defer=name&defer=age

Serialize only the id and name fields.

{
    "count": 198,
    "next": "http://127.0.0.1:8000/api/users/?defer=name&defer=age&page=1",
    "previous": null,
    "results":[
        {
            "id": 1,
        },
        ...
    ],
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drf_restricted_fields-0.0.1.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distribution

drf_restricted_fields-0.0.1-py2.py3-none-any.whl (4.9 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page