Django- how to add another field to a table displayed in a web page
<p>I am debugging a Django project, and want to display another field from the database in a table on the webpage.</p>

<p>The Django HTML for the table as it's currently displayed in the webpage is:</p>

<pre><code>&lt;table class="multisection pipeline left"&gt;
        &lt;tr class="sub-summary"&gt;
             &lt;th colspan="4"&gt;&lt;a href="?detailed_status={{detailed_status}}"&gt;&lt;h3 class="p-l-sm"&gt;{{detailed_status_str}}&lt;/h3&gt;&lt;/a&gt;&lt;/th&gt;
             {% if total_i %}&lt;th&gt;Initial exc VAT: {{total_i|money:"£"}}&lt;/th&gt;{% endif %}
             {% if total_u %}&lt;th&gt;Latest exc VAT: {{total_u|money:"£"}}&lt;/th&gt;{% else %}
             &lt;th&gt;&lt;/th&gt;
             {% endif %}
        &lt;/tr&gt;
    &lt;/table&gt;
    &lt;table class="multisection pipeline left m-b-xl"&gt;
        &lt;tr class="summary"&gt;
            &lt;th style="width: 3em;"&gt;&lt;/th&gt;
            {% for field in fields %}
                &lt;th class="text-sm p-l-sm p-t-sm p-b-sm" style="width:{{widths|getval:forloop.counter0}}"&gt;
                {% if field.1 %}
                    {% if sort == field.0 and not reverse %}
                        &lt;a href="?sort=-{{field.0}}&amp;detailed_status={{detailed_status}}"&gt;{{field.0}}&lt;/a&gt;
                    {% else %}
                        &lt;a href="?sort={{field.0}}&amp;detailed_status={{detailed_status}}"&gt;{{field.0}}&lt;/a&gt;
                    {% endif %}
                {% else %}
                    {{field.0}}
                {% endif %}
                &lt;/th&gt;
                {# Make all have the same number of columns (8) #}
                {% if forloop.last %}
                    {% for i in ',,,,,,,,' %}
                        {% if forloop.counter|add:forloop.parentloop.counter0 &lt; 11 %}
                            &lt;th&gt;&amp;nbsp;&lt;/th&gt;
                        {% endif %}
                    {% endfor %}
                    {% if detailed_status == "ds4"|ds %}
                        &lt;th&gt;&lt;/th&gt;
                    {% endif %}
                {% endif %}
            {% endfor %}
        &lt;/tr&gt;
        {% with user.employee.full_name|is:'Nick Ross' as summary_link %}

        {% for project in projects %}
            &lt;tr data-project-id="{{project.id}}" class="{% cycle 'odd' 'even' %}{% if project.office == 2 %} col{% endif %}"&gt;
                {% with initial_details=project.initial_details survey=project.survey  %}
                    {# Open lightbox #}
                    &lt;td&gt;
                        {% if user.is_superuser %}
                            &lt;a class="gallery-loader" data-project-id="{{project.id}}"&gt;&lt;i class="icon info"&gt;&lt;/i&gt;&lt;/a&gt;

                            {% if forloop.first and first_table %}
                                &lt;div id="iframe_gallery_wrap"&gt;

                                    &lt;a href="#p1" class="gallery"&gt;
                                        &lt;div id="p1"&gt;
                                            &lt;iframe class="lightbox-content" src="{% url 'projects:description' project.id %}report/" width="1200" height="800" id="p1" style="border:none;" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""&gt;&lt;/iframe&gt;
                                        &lt;/div&gt;
                                    &lt;/a&gt;
                                    &lt;a href="#p2" class="gallery"&gt;
                                        &lt;div id="p2"&gt;
                                            &lt;iframe class="lightbox-content" src="{% url 'projects:survey' project.id %}report/" width="1200" height="800" id="p1" style="border:none;" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""&gt;&lt;/iframe&gt;
                                        &lt;/div&gt;
                                    &lt;/a&gt;
                                    &lt;a href="#p3" class="gallery"&gt;
                                        &lt;div id="p3"&gt;
                                            &lt;iframe class="lightbox-content" src="{% url 'projects:preconcept_notes' project.id %}report/" width="1200" height="800" id="p1" style="border:none;" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""&gt;&lt;/iframe&gt;
                                        &lt;/div&gt;
                                    &lt;/a&gt;
                                    &lt;a href="#p4" class="gallery"&gt;
                                        &lt;div id="p4"&gt;
                                            &lt;iframe class="lightbox-content" src="{% url 'projects:concept' project.id %}report/" width="1200" height="800" id="p1" style="border:none;" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""&gt;&lt;/iframe&gt;
                                        &lt;/div&gt;
                                    &lt;/a&gt;
                                    &lt;a href="#p5" class="gallery"&gt;
                                        &lt;div id="p5"&gt;
                                            &lt;iframe class="lightbox-content" src="{% url 'projects:handover' project.id %}report/" width="1200" height="800" id="p1" style="border:none;" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""&gt;&lt;/iframe&gt;
                                        &lt;/div&gt;
                                    &lt;/a&gt;
                                &lt;/div&gt;
                            {% endif %}
                        {% endif %}

                    &lt;/td&gt;
                    {# Standard columns #}
                    {% with project.team as team %}

                    &lt;td&gt;&lt;a href="{% if summary_link %}{% url 'projects:summary' project.id %}{% else %}{% url 'projects:details' project.id %}{% endif %}"&gt;{{project.project_name}}&lt;/a&gt;&lt;/td&gt;
                    &lt;td&gt;{{project.town|xor}}&lt;/td&gt;
                    &lt;td&gt;{{project.postcode}}&lt;/td&gt;
                    &lt;td&gt;{{project.client.full_name_a|xor}}&lt;/td&gt;
                    {# Status-specific columns #}
                    {% if detailed_status == "ds1"|ds or detailed_status == "ds2"|ds %} {# New project leads #}
                        &lt;td&gt;{{project.created|date:"d/m/y"}}&lt;/td&gt;
                        &lt;td&gt;{{initial_details.site_visit.date|date:"d/m/y"}}&lt;/td&gt;
                        &lt;td&gt;{{initial_details.discussed_budget|money:'£'|xor}}&lt;/td&gt;
                        &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                        &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                    {% elif detailed_status == "ds3"|ds %} {# CDI Sent #}
                        &lt;td&gt;{{project.cdi.sent|date:"d/m/y"}}&lt;/td&gt;
                        &lt;td&gt;{{initial_details.discussed_budget_updated|money:"£"|xor}}&lt;/td&gt;
                        &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                        &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                        &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                    {% elif detailed_status == "ds4"|ds %} {# CDI Signed #}
                        &lt;td&gt;{{team|getval:'Designer'|xor}}&lt;/td&gt;
                        &lt;td&gt;{{project.budget_overview.current_exc_vat|money:"£"|xor}}&lt;/td&gt;
                        &lt;td&gt;{{project.survey.meeting.date|date:"d/m/y"}}&lt;/td&gt;
                        &lt;td&gt;{% for emp in project.survey.get_surveyors %}{{emp}}, {% endfor %}&lt;/td&gt;
                        &lt;td&gt;{{initial_details.estimated_start|date:"m/Y"}}&lt;/td&gt;
                        &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                    {% elif detailed_status == "ds5"|ds %} {# Survey completed #}
                        &lt;td&gt;{{team|getval:'Designer'|xor}}&lt;/td&gt;
                        &lt;td&gt;{{project.budget_overview.updated_exc_vat|money:"£"|xor}}&lt;/td&gt;
                        &lt;td&gt;{{initial_details.preconcept_meeting.date|date:"d/m/y"}}&lt;/td&gt;
                        &lt;td&gt;{{initial_details.first_presentation.presentation_date|date:"d/m/y"}}&lt;/td&gt;
                        &lt;td&gt;{{initial_details.estimated_start|date:"m/Y"}}&lt;/td&gt;
                    {% elif detailed_status == "ds6"|ds %} {# Tendering/costing drawings #}
                        &lt;td&gt;{{team|getval:'Designer'|xor}}&lt;/td&gt;
                        &lt;td&gt;{{project.budget_overview.updated_exc_vat|money:"£"|xor}}&lt;/td&gt;
                        &lt;td&gt;{{initial_details.estimated_start|date:"m/Y"}}&lt;/td&gt;
                        &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                        &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                    {% elif detailed_status == "ds7"|ds %} {# Post presentation #}
                        &lt;td&gt;{{team|getval:'Designer'|xor}}&lt;/td&gt;
                        &lt;td&gt;{{project.budget_overview.updated_exc_vat|money:"£"|xor}}&lt;/td&gt;
                        &lt;td&gt;{{project.chance}}{% if project.chance %}%{% endif %}&lt;/td&gt;
                        &lt;td&gt;{{initial_details.last_presentation.date|date:"d/m/y"}}&lt;/td&gt;
                        &lt;td&gt;{{initial_details.estimated_start|date:"m/Y"}}&lt;/td&gt;
                    {% else %}
                        {# Standard-ish columns #}
                        &lt;td&gt;{{team|getval:'Architect'|xor}}&lt;/td&gt;
                        &lt;td&gt;{{project.budget_overview.updated_exc_vat|money:"£"|xor}}&lt;/td&gt;
                        &lt;td&gt;{{project.live_date|date:"d/m/y"}}&lt;/td&gt;
                        &lt;td&gt;{{initial_details.desired_start|date:"d/m/y"}}&lt;/td&gt;
                        &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                    {% endif %}
                    &lt;!--ERF(09/11/2016 @ 1540) Add an 'elif' for the site manager (ds9 is the 'Live Project' table) --&gt;
                    {% if detailed_status == "ds9"|ds %}
                        &lt;td&gt;{{team|getval:'Site manager'|xor}}&lt;/td&gt;
                        &lt;!--td&gt;{{project.site_manager}}&lt;/td--&gt;
                    {% endif %}

                        {% if user.is_staff or user.is_superuser %}
                            &lt;td&gt;
                                &lt;a class="delete double-check m-l-xl" data-view-url="{% url 'projects:delete' project.id %}"&gt;&lt;img class="icon" src="{% static "img/bin.png" %}"&gt;&lt;/a&gt;
                            &lt;/td&gt;
                        {% endif %}
                        &lt;td data-view-url="{% url 'projects:update_detailed_status' project.id %}" style="width:10em;"&gt;
                            {{detailed_status_changer.visible_fields.0}}
                        &lt;/td&gt;
                    {% endwith %}

                {% endwith %}

            &lt;/tr&gt;
        {% endfor %}
        {% endwith %}

    &lt;/table&gt;
</code></pre>

<p>and this is currently showing a table with the following column headings:</p>

<p>Project name, Town, Postcode, Contact Name</p>

<p>These column heading are fields belonging to the Class <code>Project</code>, which is defined in the <code>models.py</code> file:</p>

<pre><code>class Project(models.Model):
    ...
    ds2 = 20
    ...
    ds9 = 120
    ...
    ds13 = 200

    DETAILED_STATUS_CHOICES = (
        ...
        ds9, 'Live project'),
        ...
    )

    # Several form fields added here, e.g. 
    employees = models.ManyToManyField(Employee, through=ProjectEmployee)
    client = models.ForeignKey(Client, on_delete=models.SET_NULL, null=True, blank=True)

    # Several 'def's here, e.g.
    def team(self):
        employees = self.assigned.all()
        ...
        sm = [person for person in employees if person.role==Role.SM]
        ...
        return{
            ...
            'Site manager': sm[0].employee.first_name if sm else '',
            ...
        }

    # Several `@property` definitions here, e.g.
    @property
    def estimated_compeltion(self):
        ...
</code></pre>

<p>I want to display the <code>Site manager</code> field from the database in the table on the webpage- I tried adding it to the <code>Python</code> code as shown above, but this hasn't made a difference to what is displayed on the webpage, even though that appears to be exactly the same way that all of the other fields from the database are displayed.</p>

<p>What am I missing here? I would expect the Django HTML to display every field that I am telling it to in the Python code, since I am using <code>forloop</code>s to get the fields... Why is it that I can't see the 'Site manager' field that I've added to the code in the table on the HTML web page?</p>