filtering objects in django templates code example

Example 1: objects.filter django

>>> Entry.objects.filter(blog_id=4)

Example 2: filtering objects in django templates

@register.filter
def in_category(things, category):
    return things.filter(category=category)

{% for category in categories %}
  {% for thing in things|in_category:category %}
    {{ thing }}
  {% endfor %}
{% endfor %}

Example 3: filtering objects in django templates

{% for category in categories %}
  {% for thing in things|in_category:category %}
    {{ thing }}
  {% endfor %}
{% endfor %}