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.captain'])
# {
# '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.0.tar.gz
(2.7 kB
view hashes)
Built Distribution
Close
Hashes for dictfilter-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5807203d9e5e579640ac90eac3fa6c566be3ef243213dab7e949e6fd1474d22 |
|
MD5 | ccebbecb761785f21384d00ed1b6674f |
|
BLAKE2b-256 | e6b9580ba197d848b953ffde81e6dd3c1fc316299c573bf41a844308850367a4 |