@register.filter
def quantity_ordered(product, order):
    """
    e.g. {% if product|quantity_ordered:plata.order > 0 %} ... {% endif %}
    """
    try:
        return order.items.values('quantity').get(product=product)['quantity']
    except __HOLE__:
        return 0
dataset/ETHPy150Open matthiask/plata/plata/shop/templatetags/plata_tags.py/quantity_ordered