/djangorestframework-queryfields

Allows clients to control which fields will be sent in the API response

Primary LanguagePythonMIT LicenseMIT

Django REST framework QueryFields

travis coveralls 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.8+, 2.0 (Python 3 only), 1.7 (DRF 2 only). Check the CI matrix for details.

Documentation is hosted on Read The Docs.