Browse Source

Template tag para acessar itens em dicionários pelo índice

pull/166/head
Sesóstris Vieira 1 year ago
parent
commit
56c4c9c9d4
  1. 14
      sigi/apps/utils/templatetags/dict_get.py

14
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
Loading…
Cancel
Save