Как загрузить ExcelDownload в Django
my modules.py
**modules.py**
def getAnswerStats(year, month):
answer_stats = Lawyer.objects.raw(''' select
select * from (
select
y.lawyer_name,
DATE_FORMAT(y.register_date, '%Y-%m-%d') as reg_date,
(select count(counsel_answer_idx) from counsel_answer where lawyer_idx = y.lawyer_idx and DATE_FORMAT(register_date, '%Y%m') = '%s') as cnt,
(select count(counsel_answer_idx) from counsel_answer where lawyer_idx = y.lawyer_idx and DATE_FORMAT(register_date, '%Y%m') = '%s' and week(register_date,5) - week(DATE_SUB(register_date,INTERVAL DAYOFMONTH(register_date)-1 DAY),5) = 1) as cnt1
where y.lawyer_status = 'N'
) A order by A.cnt desc ''', (year+month, year+month, year+month, year+month, year+month, year+month, year+month))
return answer_stats
admin_view.py
@csrf_exempt
def answer_stats_excel(request):
if request.method == "POST":
year = request.POST.get("year")
month = request.POST.get("month")
print(year+month)
stats_data = getAnswerStats(year, month)
return redirect('/admin/visual/answer_stats')
Данные stats_data извлекаются из модуля.
answer_stats.html
<form id="boardFrm" name="boardFrm" enctype="multipart/form-data" action="/admin/visual/answer_stats_excel" method="post">
<div class="form-inline">
<select class="form-control " style="width:49%" id="year" name="year"></select>
<select class="form-control " style="width:49%" id="month" name="month"></select>
</div>
<button type="submit" style="margin-top:20px;" name="button"> excel down</button>
</form>
Кнопка ExcelDownload здесь Как мне загрузить кнопку Exceldown, когда я нажимаю ее?