New filter: is_not_a #165

arjan opened this Issue Sep 5, 2011 · 2 comments


None yet
2 participants

arjan commented Sep 5, 2011


is_not_a mirrors is_a. It is particularly useful when iterating over a category and excluding members of a sub-category (iterating over all images associated with a page except images in the thumbnail category).

The attached patch adds this filter. To reduce code duplication, it factorizes the behavior of filtering over a list (or a single item), including the optional argument to return the first n matching ids. is_visible and is_a are now based on the common module.


arjan commented Sep 5, 2011

How is this different from using:

{% if not(m.rsc[id]|is_a:"article") %}

basically you can put not() around any expression..

_Commented on Google Code by _scherpenisse**


arjan commented Sep 5, 2011

I might have missed something. The form returning a boolean when passed a single item is only provided for completeness. I use is_not filter with a list :

{% with m.rsc[id].media|without_embedded_media:id|is_not_a:"thumbnail" as media %}
{% if media %}
{% for m in media %}
<li {% if forloop.first %} class="show" {% endif %} >

{% endfor %}
{% endif %}
{% endwith %}

Can I do the same thing with not() ?

_Commented on Google Code by**

mworrell closed this in 2a8a2a5 Oct 3, 2011

@rpip rpip pushed a commit to rpip/zotonic that referenced this issue Aug 12, 2013

@mworrell mworrell Fixes #165. With thanks to Paul Guyot. 43f6e9b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment