Django filter all that has certain names -


i have problem similar django filter queryset __in *every* item in list

i need select prospects have certifications defined by

class prospect(models.model):     certification = models.manytomanyfield(certification, blank=true, related_name="certification_prospects")  class certification(models.model):     name = models.charfield(max_length=200, null=true, blank=true) 

for example, if have certifications ['cpa', 'phd'] want prospects have cpa & phd, if have more or less two, want exclude them.

i'm using solution, give link earlier

def searchforprospectbycertifications(prospects, certifications):     prospects = prospects.filter(certification__in=certifications).annotate(num_certifications=count('certification')).filter(num_certifications=len(certifications))      return prospects 

but i'm receiving error of valueerror: invalid literal int() base 10: 'cpa'

try it:

prospects.filter(certification__name__in=certifications) 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -