跳转到主要内容

限制DRF序列化器返回的字段

项目描述

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

特性

使用“only”查询参数限制DRF序列化器返回的字段

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

仅序列化“id”和“name”字段。

{
    "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”查询参数延迟DRF序列化器返回的字段

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

仅序列化“id”和“name”字段。

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

项目详情


下载文件

下载适合您平台的应用程序。如果您不确定要选择哪个,请了解更多关于 安装软件包 的信息。

源分布

drf_restricted_fields-0.0.1.tar.gz (6.9 kB 查看哈希)

上传时间:

构建分布

drf_restricted_fields-0.0.1-py2.py3-none-any.whl (4.9 kB 查看哈希)

上传于 Python 2 Python 3

由以下支持