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
Release history Release notifications | RSS feed
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.1.tar.gz
(12.3 kB
view details)
Built Distribution
File details
Details for the file dictfilter-2.0.1.tar.gz
.
File metadata
- Download URL: dictfilter-2.0.1.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd5fca31d157eced8051d3a6d4da452e6d684e397bc0d58509ccb8d007850d4a |
|
MD5 | 83d13b67cae08424f4b922d0879e89e5 |
|
BLAKE2b-256 | 4aa66972cb1f5276244fecdb5648687f03ba36e5077c4dec99753bcae2867190 |
Provenance
File details
Details for the file dictfilter-2.0.1-py3-none-any.whl
.
File metadata
- Download URL: dictfilter-2.0.1-py3-none-any.whl
- Upload date:
- Size: 5.5 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4639d302756677c96d0255d6307dd2df4334351d7240c022e829172941fee72 |
|
MD5 | 393c8670855a1bf9aa99364d1b37fec9 |
|
BLAKE2b-256 | a06140efc8a4d5a1cfbe6bbf39d783a811b5cc378e4adab3cd20ff1b0f683c6d |