always return the same pdf
MRAB
python at mrabarnett.plus.com
Mon Mar 7 14:10:49 EST 2022
On 2022-03-07 14:08, Gonzalo V wrote:
> Hello everyone.
> i had upload a Django app to an ubuntu 18.04 server and it gives me the
> same pdf everytime the view is called. To generate the pdf it receipts
> differents string buy it gives me the same pdf. Could you give some idea
> what is happening?
>
> thanks everyone
> @never_cached
> def generar_pdf(request):
> prueba = request.session.get('contenedor')
> cantidad_preguntas=prueba['cantidad_preguntas']
> archivo_salida = open("prueba.tex","w")
>
> archivo_salida.write("\\documentclass[10pt,oneside,letterpaper]{article}")
> archivo_salida.write("\\usepackage[utf8x]{inputenc}")
>
> ##hace mas y mas cosas sin importancia con latex que funcionan bien
>
> archivo_a_descargar = open("prueba.pdf","rb") #
> respuesta =
> HttpResponse(archivo_a_descargar,content_type='application/pdf')
> respuesta['Content-Disposition'] = 'attachment; filename="{0}"'.format(
> archivo_a_descargar.name)
>
> return respuesta
> Saludos,
> Gonzalo
You're using relative paths. Are you sure that they are pointing to the
correct files?
Is it actually generating the PDF?
You might think that when it generates the PDF it overwrites any
existing file of that name but is it? Is it simply giving you the PDF
that's already there?
More information about the Python-list
mailing list