Added get_value_from_dict filter to obtain values from a dict in templates

This commit is contained in:
PCoder 2017-06-29 13:05:06 +05:30
parent a3c3a5cd2e
commit 3313dab485

View file

@ -21,4 +21,14 @@ def change_lang(context, lang=None, *args, **kwargs):
activate(cur_language) activate(cur_language)
return "%s" % url return "%s" % url
@register.filter('get_value_from_dict')
def get_value_from_dict(dict_data, key):
"""
usage example {{ your_dict|get_value_from_dict:your_key }}
"""
if key:
return dict_data.get(key)
else :
return None