# Filter for EACH element in Array/JSONB field possible?

**URL:** <https://forum.djangoproject.com/t/filter-for-each-element-in-array-jsonb-field-possible/10763>\
**Category:** Using Django\
**Created:** [December 1, 2021, 8:28pm UTC](https://forum.djangoproject.com/t/filter-for-each-element-in-array-jsonb-field-possible/10763 "2021-12-01T20:28:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tobiaskatch](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/tobiaskatch/32/5991_2.png) [@tobiaskatch](https://forum.djangoproject.com/u/tobiaskatch)\
**Post date:** [December 1, 2021, 8:28pm UTC](https://forum.djangoproject.com/t/filter-for-each-element-in-array-jsonb-field-possible/10763/1 "2021-12-01T20:28:24Z")

</div>

Hello Django community!

I would like to filter my database using a contained\_by operation on each element in a Array/JSONB field.  
Example:

Instance has arrayfield: [[A, B],[C, D, E]]

I would like to apply the follwing filter to find this instance (written like python in-line loop):

.filter(array\_element contained by [A, B, C, D, E] for array\_element in array)

Because the arrayfield can have variable length I cannot index each contains operation explicitly. Is there a way in Django to do something like this?

Thank you for you help!

---

<div class="post-metadata">

**Author:** ![CodenameTim](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/codenametim/32/31507_2.png) [@CodenameTim](https://forum.djangoproject.com/u/CodenameTim)\
**Post date:** [December 1, 2021, 8:37pm UTC](https://forum.djangoproject.com/t/filter-for-each-element-in-array-jsonb-field-possible/10763/2 "2021-12-01T20:37:26Z")

</div>

Please try to avoid creating duplicate threads for the same question on the forum.
