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

330
Views
Django object manager 'lower' parameter

I am trying to filter out a queryset based on if one of its field names is in a list of lower case values. The trouble is that some of these field values have capital letters, so I can't do

all_listings = all_listings.objects.filter(make__name__in=makes)

Is there a possible way to say something along the lines of

all_listings = all_listings.objects.filter(make__name__lower__in=makes)
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You can try to use Lower func

from django.db.models.functions import Lower

all_listings = all_listings.objects.annotate(name_lower=Lower('make__name')).filter(name_lower__in=makes)
over 4 years ago · Santiago Trujillo Report

0

You can do

all_listings = all_listings.objects.filter(make__name__iregex=r'(' + '|'.join(makes) + ')')
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!