mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-03-27 03:41:21 +01:00
feat(common:templatetags): add templatetag to programmatically retrieve a dict key
This commit is contained in:
11
app/apps/common/templatetags/tools.py
Normal file
11
app/apps/common/templatetags/tools.py
Normal file
@@ -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