1.views.py

def scheduling(request):
    cursor = connection.cursor()
    cursor.execute("select staff_name from alarm_platform.TBL_STAFF where staff_number=any(select duty_staff_number1 from alarm_platform.TBL_DUTY);",None)
    people_list = cursor.fetchall()
    print(people_list)
    return render(request, "people_list.html", {"people_list": people_list})  # 返回界面
  1. 模板文件
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Store</title>
</head>
<body>
<table border="1">
    <thead>
    <tr>
        <th>第一</th>
    </tr>
    </thead>
    <tbody>
    {% for people_list in people_list %}
        <tr>

            <td>{{ people_list.0 }}</td>
        </tr>
    {% endfor %}
    </tbody>
</table>

你可以在模板把 {{ chika }} 打印出来:

(('wangxa',), ('wangcha',), ('liuli',), ('wangkke',))
  {% for people_list in people_list %}
     {{ people_list.0 }} {{ people_list.1}} {{ people_list.2 }}   
{% endfor %}