{% if result_hidden_fields %}
<div class="hiddenfields"> {# DIV for HTML validation #}
{% for item in result_hidden_fields %}{{ item }}{% endfor %}
</div>
{% endif %}

{% if results %}
<div class="result-list">
    <table cellspacing="0">
        <thead>
            <tr>
                {% for header in result_headers %}
                <th{{ header.class_attrib }}>
                {% if header.sortable %}<a href="{{ header.url }}">{% endif %}
                {{ header.text|capfirst }}
                {% if header.sortable %}</a>{% endif %}</th>{% endfor %}
            </tr>
        </thead>
        <tbody>
        {% for result in results %}
            <tr class="{% cycle 'row1' 'row2' %}">{% for item in result %}{{ item }}{% endfor %}</tr>
        {% endfor %}
        </tbody>
    </table>
</div>
{% endif %}


{% if result_hidden_fields %}
<div class="hiddenfields"> {# DIV for HTML validation #}
{% for item in result_hidden_fields %}{{ item }}{% endfor %}
</div>
{% endif %}

{% if results %}
<div class="result-list">
    <table cellspacing="0">
        <thead>
            <tr>
                {% for header in result_headers %}
                <th{{ header.class_attrib }}>
                {% if header.sortable %}
                {% if header.url %}
                <a href="{{ header.url }}">
                {% else %}
                <a href="{{ header.url_primary }}">
                {% endif %}
                {% endif %}
                {{ header.text|capfirst }}
                {% if header.sortable %}</a>{% endif %}</th>{% endfor %}
            </tr>
        </thead>
        <tbody>
        {% for result in results %}
            <tr class="{% cycle 'row1' 'row2' %}">{% for item in result %}{{ item }}{% endfor %}</tr>
        {% endfor %}
        </tbody>
    </table>
</div>
{% endif %}

Update to Django 1.4's format for column sorting.
Update to Django 1.4's format for column sorting.
