Why is my form loading by each item but not by a for loop?

I have a template that loads a form. I have tried to use a loop to load all the items from the form but it doesn’t work. I’m thinking it’s something ridiculous I’m missing because it will load the items individually. Can anyone see what I’m missing! ? I am putting both the individual loaded items with the for loop beneath. Again it will individually load without a problem but the loop won’t work!?

template:

 <form method="POST" action="{% url 'pt-search' %}" id="search_form">
                {% csrf_token %}
                
                <div class="form-section form-floating mb-3">
                    <div class="form-group mb-3">
                    <input type="text" class="form-control" id="search_fn" name="search" placeholder="First Name">{{ searchform.first_name }}
                    </div>
                    <div class="form-group mb-3">
                    <input type="text" class="form-control" id="search_ln" name="search" placeholder="Last Name">{{ searchform.last_name }}
                    </div>
                    <div class="form-group mb-3">
                    <input type="date" class="form-control" id="search_dob" name="search" placeholder="Date of Birth">{{ searchform.dob }}
                    </div>
                    <div class="form-group mb-3">
                    <input type="number" class="form-control" id="search_ssn" name="search" placeholder="SSN">{{ searchform.ssn }}
                    </div>
                    <div class="form-group mb-3">
                    <input type="number" class="form-control" id="search_mrn" name="search" placeholder="MRN">{{ searchform.mrn }}
                    </div>

                    {% for item in searchform %}
                    <div class="form-group mb-3">
                        <div class="form-label">{{ item.label }}:</div>
                        <div class="form-item">{{ item }}</div>
                        <div class="form-errors">{{ item.errors }}</div>
                    </div>
                    {% endfor %}
                </div>
                
            </form> 

are you sure send form in context as named by “searchform”?

Can you share the rendered result?

Additionaly,

  1. The fields are manually rendered first (e.g., {{ searchform.first_name }}, {{ searchform.last_name }}, etc.). And then, there’s a loop that renders all the form fields again {% for item in searchform %}.
    What is the output?
    Which fields have any value?

  2. Try this and post the error results if there are any:

<form method="POST" action="{% url 'pt-search' %}" id="search_form">
    {% csrf_token %}
    <div class="form-section form-floating mb-3">
        {% for field in searchform %}
            <div class="form-group mb-3">
                <label for="{{ field.id_for_label }}" class="form-label">{{ field.label }}:</label>
                {{ field }}
                {% if field.errors %}
                    <div class="form-errors">{{ field.errors }}</div>
                {% endif %}
            </div>
        {% endfor %}
    </div>
</form>