mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-11-27 19:02:54 +01:00
feat(common:templatetags): add templatetag to programmatically retrieve a dict key
This commit is contained in:
1 parent
c786697836
commit
315d68ba15
1 file changed
+11
@@ -0,0 +1,11 @@
|
||||
from django import template
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.filter
|
||||
def get_dict_item(obj, key):
|
||||
if isinstance(obj, dict):
|
||||
return obj.get(key)
|
||||
|
||||
return obj
|
||||
Reference in new issue
Block a user