# filter

Source: https://zotonic.com/docs/1566/filter

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

Language: en



Filters a list on the value of a property, either on presence or equality.

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

To filter a list of values:

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

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

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

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

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

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

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

A second argument can be added to test on equality:

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

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

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/1566?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/1566?language=en>)
