diff --git a/sigi/apps/utils/templatetags/dict_get.py b/sigi/apps/utils/templatetags/dict_get.py new file mode 100644 index 0000000..96733d2 --- /dev/null +++ b/sigi/apps/utils/templatetags/dict_get.py @@ -0,0 +1,14 @@ +from django import template +from django.conf import settings +from django.templatetags.static import static + +register = template.Library() + + +@register.filter +def get(d, key_name): + try: + value = d[key_name] + except KeyError: + value = settings.TEMPLATE_STRING_IF_INVALID + return value