Troubles With Downloading And Saving A Document In Django
I have a few problems, cannot figure it out, maybe there are connected. Problem 1.1: file is exported in django documentation and it works, but when I try to rename it, it has some
Solution 1:
output = io.BytesIO()
You created here was not used at all.
try changing
with pd.ExcelWriter('output.xlsx') as writer:
to
writer = pd.ExcelWriter(output)
Otherwise the BytesIO might be closed by the ExcelWriter, then Django would try to close it again. Giving you the double close error.
Your problem 2 seems to be a type error.
filename = newdoc + '_calculated.xlsx'
your newdoc here is not a string, but a "InMemoryUploadedFile", you probably need to access its name by doing
filename = f"{newdoc.name}_calculated.xlsx"
Post a Comment for "Troubles With Downloading And Saving A Document In Django"