我正在为运输公司开发一个应用程序,在客户端页面上,我们可以添加送货之旅,这些送货之旅可以计划在不同的日期和时间:例子:送货之旅计划在周一下午 4 点和周四上午 10 点进行。目前,我将其以 JSON 格式存储在我的 SQLAlchemy Delivery Tour 数据库中,如下所示:{'星期一':10,'星期四':16}但问题是当我呈现 HTML 文件时,我无法成功地遍历 JSON 文件并将正确的日期和时间与正确的交付之旅相关联......所以我想知道有没有更有效的方法来做到这一点?就像可能创建一个新表,但我不知道如何排列列。编辑我的 HTML :<div class="card"> <div class="card-header-spe"> <p style="text-align:left;"> Delivery Tour <span style="float:right;"> <a class=" card-category btn btn-primary" href="{{ url_for('deliver', client_id=client.id )}}">Add New</a> </span> </p> </div> <table class="table table-striped table-hover"> <thead> <tr> <th scope="col">Title</th> <th scope="col">Description</th> <th scope="col">Schedule</th> <th scope="col">Driver</th> </tr> </thead> <tbody> <tr> {% for deliv in delivery %} <th scope="row">{{ deliv.title }}</th> <td>{{ deliv.description }}</td> <td >{{ deliv.schedule }} </td> {% if deliv.driver_assigned %} {% for d in driver %} {% if d.id == deliv.driver_assigned %} <td>{{d.first_name}}</td> {% endif %} {% endfor %} {% else %} <td></td> {% endif %} </tr> {% endfor %} </tbody> </table> </div>这是我的交付数据库的照片:
添加回答
举报
0/150
提交
取消