小编fa2*_*007的帖子

如何将 pandas DataFrame 显示到 Django 模板中?

我有一个pandasDataFrame,我想将此 DataFrame 显示到我的Django模板中。但每次代码编译成功时,我的Django网络应用程序中都不会显示任何表格。我在这里缺少什么?我的数据框看起来像这样:

在此输入图像描述

我的 html 看起来像:

<div class="row" style="margin-bottom: 20px;">
        <div class="col-md-3">

        </div>
        <div class="col-md-9">
            <div class="card" style="width: auto;">
                <div class="card-body">
                    <h3 class="h3">Total match data and Profit Mergin</h3>
                    <br>
                    <table class="table table-striped">
                        <tr>
                            <th>Total Contest</th>
                            <th>Total Entry Amount</th>
                            <th>Total Seat</th>
                            <th>Total Winning Amount</th>
                            <th>Total Team Capacity</th>
                            <th>Profit Mergin</th>

                        {% for value in final_data.iterrows %}
                            
                        <tr>
                            <td>{{ value.0 }}</td>
                            <td>{{ value.1 }}</td>
                            <td>{{ value.2 }}</td>
                            <td>{{ value.3 }}</td>
                            <td>{{ value.4 }}</td>
                            <td>{{ value.5 }}</td>
                        </tr> …
Run Code Online (Sandbox Code Playgroud)

python django pandas

4
推荐指数
2
解决办法
1万
查看次数

标签 统计

django ×1

pandas ×1

python ×1