Source

gnocchi-catalogue / catalogue / templatetags / catalogue.py

cur...@tinbrain.… 9b89ce3 









from django import template
from gnocchi_catalogue import models

register = template.Library()

@register.filter
def products_with_tags(values):
    qset = models.Product.objects.all()
    for tag in values.split():
        qset = qset.filter(tags__tag__name=tag.strip())
    return qset