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 hashes)
Built Distribution
Close
Hashes for dictfilter-2.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4639d302756677c96d0255d6307dd2df4334351d7240c022e829172941fee72 |
|
MD5 | 393c8670855a1bf9aa99364d1b37fec9 |
|
BLAKE2b-256 | a06140efc8a4d5a1cfbe6bbf39d783a811b5cc378e4adab3cd20ff1b0f683c6d |