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.0.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

dictfilter-2.0.0-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dictfilter-2.0.0.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for dictfilter-2.0.0.tar.gz
Algorithm Hash digest
SHA256 55d92dd16ae5a0e418bb95216e6debcdb81568d80fe0d1e39258ec0a7d7c17b0
MD5 74b612e9ed328734d37ec74ac33630f9
BLAKE2b-256 815b806c5f59f9e60e929b299e64a770ee33e9b8b7e57ff852418d243295d455

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: dictfilter-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for dictfilter-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 89f28ef5465e76c8c502b7244843e68cbbc50b9798ac901d190848e199313b6f
MD5 61f23027324c9fa56fe5b57342db1f40
BLAKE2b-256 7c74e246ee907e85f5f4b92b1993171101403992faf08297d16a6262c0aa972d

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