title: How to Download ExcelDownload in Django
body: <p>How to Download ExcelDownload in Django</p>
  
  <p>my modules.py</p>
  
  <pre><code>**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
  </code></pre>
  
  <p>admin_view.py</p>
  
  <pre><code>@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')
  </code></pre>
  
  <p>The stats_data is retrieved from the module.</p>
  
  <pre><code>answer_stats.html
  
      &lt;form id="boardFrm" name="boardFrm" enctype="multipart/form-data" action="/admin/visual/answer_stats_excel" method="post"&gt;
          &lt;div class="form-inline"&gt;
              &lt;select class="form-control " style="width:49%" id="year" name="year"&gt;&lt;/select&gt;
              &lt;select class="form-control " style="width:49%" id="month" name="month"&gt;&lt;/select&gt;
          &lt;/div&gt;
              &lt;button type="submit" style="margin-top:20px;" name="button"&gt; excel down&lt;/button&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>ExcelDownload button here
  How do I download the Exceldown button when I click it?</p>