title: How to read the contents of drop-down menus in Django?
body: <p>I have two drop-down menus and I want to retrieve its values to use them as variables to filter the retrieved data from an internal Web API. </p>
  
  <p><a href="https://i.stack.imgur.com/bK0P4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bK0P4.png" alt="Dropdown menus"></a></p>
  
  <p><strong>Views.py</strong></p>
  
  <pre><code># I want to retrieve the year and week number, so I can use them as values in my filter
  def filter():
      filters = {"filter": {
          "filters": [{
              "field": "DateTime",
              "operator": "gte",
              "value": "2017-07-23 23:59:59"
          }, {
              "field": "DateTime",
              "operator": "lte",
              "value": "2017-08-18 23:59:59"
          }],
          "logic": "and"
      }}
  </code></pre>
  
  <p>I did not use Django forms because I am not holding any other data than the years and I am generating the number of weeks, however, if you consider that it might be useful to use Django forms to facilitate the data handling then write your point of view, I want to make this web app better. </p>
  
  <p><strong>header.html</strong></p>
  
  <pre><code>&lt;form method="POST"&gt; {% csrf_token %}
      &lt;h6&gt;Select year&lt;/h6&gt;
      &lt;select name="select_year"&gt;
        &lt;option value = "2016" &gt;2016&lt;/option&gt;
        &lt;option value = "2017"&gt; 2017&lt;/option&gt;
        &lt;option value = "2018"&gt; 2018&lt;/option&gt;
      &lt;/select&gt;
        &lt;h6&gt;Select week&lt;/h6&gt;
        &lt;select name="select_week"&gt;
        &lt;!--range is not supported: the spaces represent the number of weeks --&gt;
       {% for week in "                                                    " %}
          &lt;option value="{{forloop.counter}}"&gt;{{forloop.counter}}&lt;/option&gt;
      {% endfor %}
      &lt;/select&gt;
      &lt;button type="submit"&gt;Search&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Caveat</strong>: I am concerned that the code to generate the week numbers is totally incorrect because it is not the right solution and I have read the following posts <a href="https://stackoverflow.com/questions/11481499/django-iterate-number-in-for-loop-of-a-template">Numeric loops in Django templates</a>, <a href="https://stackoverflow.com/questions/1107737/numeric-for-loop-in-django-templates">Iterate number in for loops</a> but this is out off topic and my priority is to get the values of these two dropdown menus. </p>