I need to do the following query:
open_positions = Jobs.objects.all()
open_positions_with_apply = open_positions.extra(`has_applied` =
JobApplication.objects.filter(profile=profile, job=job).exists()
To clarify what I want to do:
profile = UserProfile.objects.get(id=1)
new_query_set = []
for job in Jobs.objects.all():
has_applied = JobApplication.objects.filter(job=job, profile=profile)
new_query_set.append(job with its has_applied value) # in pseudocode, not sure how this would be done
Basically given a profile (the user visiting the page), and a QuerySet of jobs, I need to find a boolean of whether the user has applied. How would I do this with a django query?
For what it’s worth, I went about solving this by getting a
job_idvalues_list of the jobs the user has applied for, and in the template –