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
Post a Comment