I have the following dictionary:
d = {'name': 'Johnny', 'age': 23, '_id': 167, 'sport': 'golf'}
Using jinja2 I want to filter out (or reject) the _id key so I get the following dictionary (note this _id field is dynamic so I want to reject the key no matter what it's equal to):
{'name': 'Johnny', 'age': 23, 'sport': 'golf'}
I've tried using the built-in filters reject and rejectattr but it's not working as expected. This is what I've tried so far:
{{ d | rejectattr('_id') }}
# <generator object select_or_reject>
{{ d | rejectattr('_id', 'defined') }}
# <generator object select_or_reject>
{{ d | reject('_id', 'defined') }}
# <generator object select_or_reject>