Как в Django показать окно диаграммы печати в браузере?
Я пытаюсь получить диалоговое окно печати в моем приложении Django. В настоящее время оно загружается на моем локальном компьютере. Но когда я обслуживаю сервер apache, оно не работает.
my views.py
def download(request,lothash):
lot=lotnumber.objects.get(lot_hash=lothash)
postdata = request.POST
array = postdata.get("array", None).split(",")
template=lot.template_type
f = open(f"/home/username/public_html/nitin2/media/{template.template_file}", "r")
txt=(f.read())
df=pd.read_excel("/home/username/public_html/nitin2/media/"+str(lot.file))
df = df.reset_index()
n=1
k=0
for index, row in df.iterrows():
if n>len(array)+1:
break
if str(n) in array:
txt = txt.replace("(As Provided by Bank)", str(row['RGN_A']))
txt = txt.replace("(Customer Name)", str(row['Applicant Name']))
txt = txt.replace("(Customer Address)", str(str(row['Address1']) + " " + str(row['Address2']) + " " + str(row['Address3'])))
txt = txt.replace("(Product)", str(row['Product']))
txt = txt.replace("(LAN)", str(row['LAN']))
txt = txt.replace("(Notice Amount)", str(row['Notice Amount']))
# save FPDF() class into a
# variable pdf
pdf = FPDF()
# Add a page
pdf.add_page()
# set style and size of font
# that you want in the pdf
pdf.set_font("Arial", size = 12)
# insert the texts in pdf
newtxt=splitlinesoftext(txt)
for x in newtxt:
pdf.multi_cell(0, 5, txt = x, align = 'L',border=0)
downloads_path = str(Path('/home/username/public_html/nitin2/media/') / "Downloads/nitin").replace('\\','/')
if not os.path.isdir(f"{downloads_path}/{str(row['Applicant Name'])}"):
os.makedirs(f"{downloads_path}/{str(row['Applicant Name'])}")
pdf.output(f"{downloads_path}/{str(row['Applicant Name'])}/document.pdf", 'I')
#pdf.output(f'document.pdf', 'D')
template=lot.template_type
f = open(f"/home/username/public_html/nitin2/media/{template.template_file}", "r")
txt=(f.read())
k=k+1
n=n+1
return JsonResponse({'context': "done"})
Теперь я хочу показывать диалоговое окно загрузки. В настоящее время, если я изменяю -
`
# save the pdf with name .pdf
downloads_path = str(Path('/home/username/public_html/nitin2/media/') / "Downloads/nitin").replace('\\','/')
if not os.path.isdir(f"{downloads_path}/{str(row['Applicant Name'])}"):
os.makedirs(f"{downloads_path}/{str(row['Applicant Name'])}")
pdf.output(f"{downloads_path}/{str(row['Applicant Name'])}/document.pdf", 'I')
`
to
** pdf.output(f'document.pdf', 'D')**
>Не работает. Теперь в браузере ничего не показывает...
Также если я изменю путь на path.home downloads_path = str(Path.home() / "Downloads/nitin").replace('\\','/')
показывает мне ошибку разрешения /var/www/downlaods/