def createPdf(requst):
#jobseekerID = request.session['rec_ID']
jobseekerID = 2
cv = CV.objects.select_related('f_key_REC').get(f_key_REC = jobseekerID)
skill = Skill.objects.select_related('fk_sCV').get(fk_sCV = cv.id)
qualification = Qualification.objects.select_related('fk_qCV').get(fk_qCV=cv.id)
certification = Certification.objects.select_related('fk_cCV').get(fk_cCV = cv.id)
experience = Experience.objects.select_related('fk_eCV').filter(fk_eCV = cv.id)
template_path = 'Recruitment_App/createpdf_cv.html'
context = {
"cv": cv,
"skills" : skill,
"qualifications": qualification,
"certification": certification,
"experience": experience
}
print (cv)
print(skill)
print(experience)
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'filename="cv001.pdf"'
template = get_template(template_path)
html = template.render(context)
pisa_status = pisa.CreatePDF(html, dest=response)
print(template)
if pisa_status.err:
return HttpResponse('We had some errors <pre>' + html + '</pre>')
return response