from django import template

register = template.Library()


@register.filter
def getlist(value, key):
    """Get all values for a key from QueryDict and join with ', '."""
    if hasattr(value, 'getlist'):
        vals = value.getlist(key)
        return ', '.join(vals) if vals else ''
    return ''
