Skip to main content

Filter dictionaries based on a list of field names.

Project description

dictfilter

installation

pip install dictfilter

usage

bsg = {
    'class': 'Battlestar',
    'model': 'Jupiter',
    'name': 'Galactica',
    'crew': {
        'commander': 'William Adama',
        'xo': 'Saul Tigh',
        'cag': 'Kara Thrace',
    }
}

result = query(some_data, ['class', 'name', 'crew.commander'])

# {
#     'class': 'Battlestar',
#     'name': 'Galactica',
#     'crew': {
#         'commander': 'William Adama',
#     }
# }

django integration

Register the dictfilter middleware in settings.py:

MIDDLEWARE = [
    ...
    'dictfilter.django.middleware.DictFilterMiddleware',
]

By default, every 2xx series response will be filtered based on a comma-separated fields parameter in the query string.

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

dictfilter-2.0.2.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

dictfilter-2.0.2-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file dictfilter-2.0.2.tar.gz.

File metadata

  • Download URL: dictfilter-2.0.2.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for dictfilter-2.0.2.tar.gz
Algorithm Hash digest
SHA256 74b765f4d6776a542d8a0764a1f8a944d641ea364b1d3eb14d6b966b33dbeff9
MD5 56334b62fd97dc8ac30b6fe4e4a4019a
BLAKE2b-256 a54b7b785a70a66128425aaa9594b22049cd47dc571ce117205f7358ff487e1a

See more details on using hashes here.

Provenance

File details

Details for the file dictfilter-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: dictfilter-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for dictfilter-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 df081f8f61e786ecbcfea427cb915e618913e0811ee2c6dfb9ccf386a861639f
MD5 bfbec860d833c914422652e2f9554e4d
BLAKE2b-256 57a1fa40e17d9ba9cf1f6e97b4512dac0ba60dc3972000e6fa1f1f52eb9ba27e

See more details on using hashes here.

Provenance

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