class Competence(models.Model):
name = models.CharField()
class Worker(models.Model):
competences = models.ManyToManyField(
to=Competence,
related_name="workers"
)
objects = WorkerQueryset.as_manager()
class WorkerQueryset(query.QuerySet):
def workers_with_required_competences(self, required_competence_ids: List[int]):
# Return the workers who has ALL the competences in the given required_competence_ids
Can anyone help me on how to do the filtering?
self.filter(competences__ids__in=required_competence_ids)
I think the following will return if only one of them is true?