模板渲染期间的KeyError

时间:2017-07-24 05:21:48

标签: django

我在使用django tables2填充表时面临KeyError。 我没有使用django模型并直接使用django行查询。

模板渲染期间出错

在模板C:\ Users \ Shariq \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ django_tables2 \ templates \ django_tables2 \ table.html中,第11行出错

state_name
1   {% load django_tables2 %}
2   {% load i18n %}
3   
4   <div class="table-container">
5   {% block table %}
6   <table{% if table.attrs %} {{ table.attrs.as_html }}{% endif %}>
7       {% block table.thead %}
8       {% if table.show_header %}
9       <thead>
10          <tr>
11          {% for column in table.columns %}
12              {% if column.orderable %}
13              <th {{ column.attrs.th.as_html }}><a href="{% querystring table.prefixed_order_by_field=column.order_by_alias.next %}">{{ column.header }}</a></th>
14              {% else %}
15              <th {{ column.attrs.th.as_html }}>{{ column.header }}</th>
16              {% endif %}
17          {% endfor %}
18          </tr>
19      </thead>
20      {% endif %}

views.py

def people(request): 
    cursor = connection.cursor() 
    cursor.execute("SELECT * FROM country_details") 
    Result_List = cursor.fetchall() 
    list = country_detailstable(Result_List) 
    RequestConfig(request).configure(list) 
    return render(request, "tables_dynamic.html", {'row': list})

0 个答案:

没有答案