Answer the question
In order to leave comments, you need to log in
How to pass a variable between different views?
Good afternoon!
Task: export a table to Excel, consisting of user-defined parameters.
Description:
There are two templates:
1. On the first template, a form with parameters for searching in the database (1 view).
2. A table consisting of parameters is returned to the second template in the first form. (2 view)
Also on this template there is a link, when clicked, it should, in theory, load an Excel file.
3. I use the ExcelResponse packer.
I tried to implement it like this: I gave the link from view2 a redirect to the third template. I registered a regular expression in urls and made a function in view. (view3)
I also tried to simply call the function to create excel. <a href="{% url 'createExcel' %}">
The problem is that it does not work out to send a queryset request (a variable where all the data was found, according to the required parameters) from view2 to view3 in order to upload them to excel.
I also tried to inherit view3 from view2 (hell begins). I tried to pass a variable to the session and take it out in view3. json serialization problems started.
By the way, I rummaged through the sea of information, there is something about it, but I still could not solve the problem.
Can someone tell me a simple way how to pass a queryset to another view and upload it to excel?
Or some other adequate way to hardcode less.
Thank you!
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question