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.2.1.tar.gz
(3.3 kB
view hashes)
Built Distribution
Close
Hashes for dictfilter-1.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10e53391d82155c3870e6f6fb21a941d4df978cb07fc305cb489da5e47b783cb |
|
MD5 | 8e06d73e3e3d0e20419298867166e43c |
|
BLAKE2b-256 | 226a8bdd23dd47a435b345e18a883c756973b28f69a69a402488f04429ca9c33 |