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

131
Views
Filter queryset only where the user is added to ManyToManyFIeld

I want to return all leads that contain a current user. How to do it?

Models.py

class CustomUser(AbstractUser):

    def __str__(self):
        return self.email


class Lead(models.Model):
    budget = models.IntegerField()
    buyer = models.ManyToManyField(CustomUser)

What queryset is expected

Lead.objects.filter(buyer__have=request.user)
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can filter with:

Lead.objects.filter(buyer=request.user)

this will make an INNER JOIN, and return only Lead objects where request.user is (one of) the buyers.

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!