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. 模板文件

    
    
    
    
    Store
    
    
    
    {% for people_list in people_list %}
        
    {% endfor %}
    
    第一
    {{ people_list.0 }}

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

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