Thanks for the first feedback, it's seems that my explanations are too confused, I add some code block and pictures to illustrate it.
So you can fill a form with a domain list on a csv file.
Domains from the list are analysed and passed to the multiresult view:
def multiresult(request, *args, **kwargs):
input_file = request.FILES['inputFile']
def several_scoring(domain_file):
domain_name_list = []
line = domain_file.readline().decode("utf-8")
while line != "":
domain_name_list.append(line)
line = domain_file.readline().decode("utf-8")
domain_list = []
for line in domain_name_list:
domain = Domain(line.rstrip())
domain.start_scanning()
domain_list.append(domain)
return domain_list
domain_list = several_scoring(input_file)
headers = domain_list[0].header_grading.displayable_list
context = {
'domain_list': domain_list,
'headers': headers,
'domain_list_dict': json.dumps([domain.__as_dict__() for domain in domain_list])
}
return render(request, "multiresult.html", context)
On the template I put a download button to save those results on a generated csv file throught a download view:
Currently the download view get domain_list_dict thanks to the url:
<a href="{% url 'domain_analyse:download' domain_list=domain_list_dict %}" method="post" >
<button type="button" class="btn btn-info btn-lg">
<i class="fa fa-download"></i> Télécharger les résultats
</button>
</a>
The download view is able to generate a csv file without problems when it gets data.
My question is how can I pass the domain_list_dict (which is in json format) to my download view without using url ? Like django automatically does with forms I wanted to change the request.POST but I don't really know how to do this. Should I use javascript in client side or is it possible to do this with jinja or django mechanism ?
If information are still missing let me know.
Thanks !