from django import template

register = template.Library()

@register.filter
def get_item(dictionary, key):
    """Retrieve dictionary item by key in Django templates."""
    if not dictionary:
        return None
    return dictionary.get(str(key)) or dictionary.get(key)
