# exclude

Source: https://zotonic.com/docs/1845/exclude

URI: https://zotonic.com/id/1845

Language: en



Filters a list on the value of a property, either on absence or inequality.

This is the inverse of <a href="/id/doc_template_filter_filter_filter" class="doc-reference doc-reference-filter"><code>filter#filter</code></a>.

Testing presence
----------------

To filter a list of values:

```django
{% print somelist|exclude:`p` %}
```

Results in a list where all elements **do not have** the property `p` defined and where the property (after conversion to boolean) is `false`.

This can be used to filter a list of resource ids on the absence of a property. For example, to see all unpublished elements in a list of resource ids:

```django
{% print [1,2,3,4,5,6]|exclude:`is_published` %}
```

To find all pages from page connection `hasdocument` that **do not have** an image:

```django
{% print id.o.hasdocument|exclude:`depiction` %}
```

Testing equality
----------------

A second argument can be added to test on inequality:

```django
{% print somelist|exclude:`title`:"Untitled" %}
```

Shows all elements whose `title` property **is not** “Untitled”.

Below is another example of inversely filtering a list:

```django
{% with m.search[{latest cat='gallery'}] as result %}
  {% if result.total > 0 %}
    {%  with result|exclude:`name`:"page_home_gallery"|random as gallery_rsc_id %}
      {% include "_gallery_widget.tpl" id=gallery_rsc_id %}
    {% endwith %}
  {% endif %}
{% endwith %}
```

The example above filters against a search result and returns only elements whose `name` **is not** “page\_home\_gallery”.

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/1845?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/1845?language=en>)
