[Answer]-Django pass a predicate to filter funtion

1👍

Because objects.filter is actually a function, you can pass it kwargs just like a normal function. So in your example you could do something like:

def search(**kwargs):
    jobs = list(Job.objects.filter(**kwargs))

search(point__distance_gte=(ref_pnt, D(**distance_from_point)))
search(point__distance_lte=(ref_pnt, D(**distance_from_point)))
👤vishen

Leave a comment