fix: Update custom_filters.py to handle both dictionary-like objects and model instances

This commit is contained in:
Lord_Devi 2024-09-18 22:33:37 -04:00
parent b87b226f5c
commit e60c7ff583

View file

@ -1,10 +1,12 @@
from django import template
register = template.Library()
@register.filter
def get_item(dictionary, key):
return dictionary.get(key)
from django import template
register = template.Library()
@register.filter
def get_item(obj, key):
if hasattr(obj, 'get'):
return obj.get(key)
return getattr(obj, key, None)
from django import template
register = template.Library()