Skip to main content

Serialize a partial subset of fields in the API

Project description

gh codecov pypi womm

Allows clients to control which fields will be sent in the API response. Fields are specified in the query, e.g.

# You want a list of users but you're only interested in the fields "id" and "username":

GET /users/?fields=id,username

[
  {
    "id": 1,
    "username": "tom"
  },
  {
    "id": 2,
    "username": "wim"
  }
]


# You want to see every field except "id" for the specific user wim:

GET /users/2/?fields!=id

{
  "username": "wim",
  "email": "hey@wimglenn.com",
  "spirit_animal": "raccoon"
}

Supported Django versions: 1.7 - 3.2+. Check the CI matrix for details.

Documentation is hosted on Read The Docs.

Developers, developers, developers!

Want to contribute to the project? This is how to run the test suite:

# get the codez
git clone https://github.com/wimglenn/djangorestframework-queryfields.git

# create and/or activate your virtualenv, this or something like it:
cd djangorestframework-queryfields
python3 -m venv .venv
source .venv/bin/activate

# installing the app in your venv
pip install --editable ".[dev]"
git checkout -b myfeature

# hack away, then ...
pytest

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

djangorestframework-queryfields-1.1.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

djangorestframework_queryfields-1.1.0-py2.py3-none-any.whl (4.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file djangorestframework-queryfields-1.1.0.tar.gz.

File metadata

File hashes

Hashes for djangorestframework-queryfields-1.1.0.tar.gz
Algorithm Hash digest
SHA256 512516947e2d0f7b132469bc3b96b702653ed032e450d90b6efc0dc7fe031ef7
MD5 2a795444c3233fb9e4014320d623ce19
BLAKE2b-256 b8838c168b6169783c41c485068ef4a606e78461c09c4ee9a04fb986c6b83c41

See more details on using hashes here.

File details

Details for the file djangorestframework_queryfields-1.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for djangorestframework_queryfields-1.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3952e02fd800de34a0fc64963bcaf7eb1e9ad688f120b1bca5b261843323f36e
MD5 ca19a914bb2d752b7f4a1929a1aab700
BLAKE2b-256 319c725493f7939ee5dc49f837b9655beb4f924c723ecc54d641539d15b47e4a

See more details on using hashes here.

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