title: Why I'm unable to download my document with django? and how to do it?
body: <p>I'm new to django and still learning, and I got here, in my own infinite loop, if I do how I sholud it be but i have an errors and it won't work, but if I do it like this there are no errors but it won't work. I want to user to be able to create excel template as he wish, this is simplified version that I want to work, just input few information and on base of that to be able to create excel template.</p>
  <p>This is <code>views.py</code></p>
  <pre><code>from django.http import HttpResponse
  from django.shortcuts import render
  import xlsxwriter
  from xlsxwriter import workbook
  from django.forms import Form, CharField, ChoiceField, IntegerField
  from django.core.validators import MaxValueValidator, MinValueValidator
  
  def home(request):
      return render(request, 'my_app/home.html')
  
  class TemplateForm(Form):
      doc_name = CharField(label='Document name')
      sheetnames = CharField(label='Sheetnames')
      choices = []
      for year in range (1900, 2050):
          choices.append( (year, year) )
      year1 = ChoiceField(label='Starting Year', initial=2021, choices=choices)
      year2 = ChoiceField(label='Ending Year', initial=2022, choices=choices)    
      row_names = CharField(label='Column names')
  
  def create_template(request):
      if request.method == 'GET':
          form = TemplateForm()
          return render(request, 'my_app/create_template.html', {'form':form})
      else:
          form = TemplateForm(request.POST)
  
  def create_form(doc_name, sheetnames, years, row_names):
      workbook = xlsxwriter.Workbook(doc_name + '_template.xlsx')
      worksheet_introduction = workbook.add_worksheet( &quot;introduction&quot; )
      for i in sheetnames:
          worksheet_data = workbook.add_worksheet(i)
          worksheet_data.write_row(0, 1, years)
          worksheet_data.write_column(1, 0, row_names)
      workbook.close()
      return workbook
  </code></pre>
  <p>This is <code>my_app/templates/my_app/create_template.html</code></p>
  <pre><code>{% extends &quot;my_app/base.html&quot; %}
  {% block content %}
  
  &lt;form action=&quot;create_template&quot; method=&quot;GET&quot;&gt;
    {% csrf_token %}
    &lt;h1&gt;Create your template&lt;/h1&gt;
    &lt;div class=&quot;item&quot;&gt;
      &lt;table&gt;
        {{ form.as_table }}
      &lt;/table&gt;
    &lt;/div&gt;
    &lt;div class=&quot;btn-block&quot;&gt;
      &lt;input type=&quot;button&quot; type=&quot;submit&quot; value=&quot;Create and Download!&quot;/&gt;
    &lt;/div&gt;
  &lt;/form&gt;
  {% endblock content %}
  </code></pre>
  <p>This is <code>my_app/urls.py</code></p>
  <pre><code>from django.urls import path
  from . import views
  
  urlpatterns = [
      path('', views.home, name='my-home'),
      path('create-template/', views.create_template, name='my-create-template'),
  ]
  </code></pre>