# Check if value exists in ArrayField in filter

**URL:** <https://forum.djangoproject.com/t/check-if-value-exists-in-arrayfield-in-filter/12396>\
**Category:** Using the ORM\
**Created:** [March 1, 2022, 2:11pm UTC](https://forum.djangoproject.com/t/check-if-value-exists-in-arrayfield-in-filter/12396 "2022-03-01T14:11:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![StijnWauterss](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/stijnwauterss/32/5475_2.png) [@StijnWauterss](https://forum.djangoproject.com/u/StijnWauterss)\
**Post date:** [March 1, 2022, 2:11pm UTC](https://forum.djangoproject.com/t/check-if-value-exists-in-arrayfield-in-filter/12396/1 "2022-03-01T14:11:02Z")

</div>

Hello I want to check if a value exists in an ArrayField in the views.

Right now i’m doing this query:

```auto
context['list'] = Customers.objects.filter(Q(postalcode__icontains = postalRepresentativeObject.postalCodes) | Q(postalcode__gte = postalRepresentativeObject.beginPostalRange) & Q(postalcode__lte = postalRepresentativeObject.endPostalRange))

```

postalcode contains 2580  
postalRepresentativeObject.postalCodes contains {2580, 2570, 2540}  
postalRepresentativeObject.beginPostalRange contains 2580  
postalRepresentativeObject.endPostalRange contains 3000

I just want to check if 2580 is inside the ArrayField object?  
Thanks

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [March 1, 2022, 3:18pm UTC](https://forum.djangoproject.com/t/check-if-value-exists-in-arrayfield-in-filter/12396/2 "2022-03-01T15:18:16Z")

</div>

See the [contains](https://docs.djangoproject.com/en/4.0/ref/contrib/postgres/fields/#contains) operator.

---

<div class="post-metadata">

**Author:** ![StijnWauterss](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/stijnwauterss/32/5475_2.png) [@StijnWauterss](https://forum.djangoproject.com/u/StijnWauterss)\
**Post date:** [March 1, 2022, 3:45pm UTC](https://forum.djangoproject.com/t/check-if-value-exists-in-arrayfield-in-filter/12396/3 "2022-03-01T15:45:51Z")

</div>

Already found it, I’m using postalcode\_\_in = postalrepresentative.postalCodes right now and it’s working as it should.
