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.dictfilter_middleware',
]
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-1.1.1.tar.gz
(2.7 kB
view hashes)
Built Distribution
Close
Hashes for dictfilter-1.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bee7f3652f6d69fbb896e8ede53256623369a22f441ee6c7763c505f1e5fe8e5 |
|
MD5 | 851290762cd79366ada9f107a0fae7d4 |
|
BLAKE2b-256 | 74f02dd1fae8e016662d7498d21489ea374639f645b61d0da28da47863c9c786 |