Added get_value_from_dict filter to obtain values from a dict in templates
This commit is contained in:
parent
a3c3a5cd2e
commit
3313dab485
1 changed files with 11 additions and 1 deletions
|
@ -21,4 +21,14 @@ def change_lang(context, lang=None, *args, **kwargs):
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue