fix: Update custom_filters.py to handle both dictionary-like objects and model instances
This commit is contained in:
parent
b87b226f5c
commit
e60c7ff583
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue