title: Set value of a select input to the value of last request in Django form template
body: <p>Here is my template code</p>
  
  <pre><code>&lt;div class="form-group row"&gt;
      &lt;label for="{{ form.diagnosis.id_for_label }}" class="col-sm-4 col-form-label col-form-label-sm"&gt;{{ form.diagnosis.label }}&lt;/label&gt;
      &lt;div class="col-sm-8"&gt;
          &lt;input type="text" class="form-control form-control-sm{% if form.diagnosis.errors %} is-invalid{% endif %}" id="{{ form.diagnosis.id_for_label }}" name="{{ form.diagnosis.html_name }}" value="{{ form.diagnosis.value }}" required&gt;
          {% if form.diagnosis.errors %}
          &lt;div class="invalid-feedback"&gt;
              {% for error in form.diagnosis.errors %}
                  {{ error }}
              {% endfor %}
          &lt;/div&gt;
          {% elif form.diagnosis.help_text %}
          &lt;small class="form-text text-muted"&gt;
              {{ form.diagnosis.help_text }}
          &lt;/small&gt;
          {% endif %}
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="form-group row"&gt;
      &lt;label for="{{ form.assigned_employee.id_for_label }}" class="col-sm-4 col-form-label col-form-label-sm"&gt;{{ form.assigned_employee.label }}&lt;/label&gt;
      &lt;div class="col-sm-8"&gt;
          &lt;select class="custom-select custom-select-sm{% if form.assigned_employee.errors %} is-invalid{% endif %}" id="{{ form.assigned_employee.id_for_label }}" name="{{ form.assigned_employee.html_name }}"&gt;
              {% for id, name in form.fields.assigned_employee.choices %}
                  &lt;option value="{{ id }}"{% if form.assigned_employee.value == id %} selected{% endif %}&gt;{{ name }}&lt;/option&gt;
              {% endfor %}
          &lt;/select&gt;
          {% if form.assigned_employee.errors %}
          &lt;div class="invalid-feedback"&gt;
              {% for error in form.assigned_employee.errors %}
                  {{ error }}
              {% endfor %}
          &lt;/div&gt;
          {% elif form.assigned_employee.help_text %}
          &lt;small class="form-text text-muted"&gt;
              {{ form.assigned_employee.help_text }}
          &lt;/small&gt;
          {% endif %}
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>As you can see, I have created the form template manually and would like to keep it that way.</p>
  
  <p>I can set the values of previously submitted fields using <code>{{ form.field.value }}</code>. But I can't do the same for the <code>&lt;select&gt;</code> fields.</p>
  
  <p>I have tried to do so using the following</p>
  
  <pre><code>{% for id, name in form.fields.assigned_employee.choices %}
      &lt;option value="{{ id }}"{% if form.assigned_employee.value == id %} selected{% endif %}&gt;{{ name }}&lt;/option&gt;
  {% endfor %}
  </code></pre>
  
  <p>. But it doesn't work except for when I set an initial value for the field like <code>form = SomeForm(initial={'assigned_employee': 20180011})</code></p>
  
  <p>The interesting thing is <code>form.assigned_employee.value</code> returns a value after submission. I have checked it using <code>console.log({{ form.assigned_employee.value }})</code>.</p>
  
  <p>But the evaluation of the following condition <code>{% if form.assigned_employee.value == id %} selected{% endif %}</code> is always <code>false</code>.</p>
  
  <p>Does anyone have a clue what's going on?</p>