Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

289
Views
How to check if a Django arrayfield has data

I have a Django model for articles with an array field that sometimes has ids.

id_list = ArrayField(models.CharField(max_length=10000), blank=True, null=True)

I want to write a query that finds all the article objects that have data in the id_list. I tried the following, but it did not work.

Article.objects.filter(id_list__isnull=False)

What is the correct way to write this? Thank you.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can use the len filter on an ArrayField and filter where the length of the array is greater than 0

Article.objects.filter(id_list__len__gt=0)
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!