Как добавить для l oop итераций django шаблонов - PullRequest
0 голосов
/ 28 апреля 2020

У меня есть страница шаблона, и я использовал модели, необходимые в файле views.py. Страница шаблона состоит из статистики по крикету и состоит из тегов tb, tr и тегов div. Мой вопрос заключается в том, где я должен использовать теги шаблона для l oop, чтобы заменить значения в соответствии с данными модели.

{% extends 'base.html' %}
<!DOCTYPE html>
<html>
{% block content %}
<head>
    <meta charset="utf-8">
    {% load staticfiles %}
    <link rel="stylesheet" href="{% static 'css/details.css' %}">
    <style>
        td,tr {
          height: 10px;
          width: 10px;
        }
        
        th, td {
          padding: 10px;
        }
        </style>
</head>

<body>

    <div class="page">
        <div id="page-wrapper" class="container" style="display:inline-block;">
            <div id="shosh" class="ad-unit shosh-embed" style="height:0; width:980px; text-align:center;"></div>
            <div style="margin-top:20px;"></div>
            <div>
                <div class="cb-col cb-col-100 cb-bg-white">
                    <div class="cb-col cb-col-20 cb-col-rt"><img height="152" width="152" title="profile image" src="{{PlayerStructure_details.imageUri.url}}"></div>
                    <div class="cb-col cb-col-80 cb-player-name-wrap">
                        <h1 itemprop="name" class="cb-font-40">{{PlayerStructure_details.firstname}} {{PlayerStructure_details.lastname}}</h1>
                        <h3 class="cb-font-18 text-gray">{{PlayerStructure_details.country}}</h3></div>
                </div>
                <div class="cb-col cb-col-100 cb-bg-grey">
                    <div class="cb-col cb-col-33 text-black">
                        <div class="cb-hm-rght">
                            <div class="cb-font-16 text-bold"> Personal Information</div>
                            <div class="cb-col cb-col-40 text-bold cb-lst-itm-sm">Born</div>
                            <div class="cb-col cb-col-60 cb-lst-itm-sm"> {{PlayerStructure_details.BirthDate}} </div>
                            <div class="cb-col cb-col-40 text-bold cb-lst-itm-sm">Birth Place</div>
                            <div class="cb-col cb-col-60 cb-lst-itm-sm"> {{PlayerStructure_details.BirthPlace}} </div>
                            <div class="cb-col cb-col-40 text-bold">Jersey No</div>
                            <div class="cb-col cb-col-60"> {{PlayerStructure_details.JerseyNumber}} </div>
                            <div class="cb-col cb-col-40 text-bold cb-lst-itm-sm">Role</div>
                            <div class="cb-col cb-col-60 cb-lst-itm-sm"> {{PlayerStructure_details.Role}} </div>
                            <div class="cb-col cb-col-40 text-bold cb-lst-itm-sm">Batting Style</div>
                            <div class="cb-col cb-col-60 cb-lst-itm-sm"> {{PlayerStructure_details.BattingStyle}}t </div>
                            <div class="cb-col cb-col-40 text-bold cb-lst-itm-sm">Bowling Style</div>
                            <div class="cb-col cb-col-60 cb-lst-itm-sm"> {{PlayerStructure_details.BowlingStyle}} </div>
                        </div>
                    </div>
                    <div class="cb-col cb-col-67 cb-bg-white cb-plyr-rt-col">
                        <div class="cb-hm-rght cb-player-bio">
                            <div class="cb-plyr-tbl">
                                <div class="cb-font-16 text-bold cb-lst-dom">Batting Career Summary</div>
                                <table  class="table cb-col-30 cb-plyr-thead">
                                    <thead>
                                        <tr class="cb-bg-grey cb-font-8">
                                            <th></th>
                                            <th class="cb-plyr-th text-right" title="Matches Played">M</th>
                                            <th class="text-right" title="No of Innings Batted">Inn</th>
                                            <th class="text-right" title="No of Not Outs">NO</th>
                                            <th class="text-right" title="No of Runs Scored">Runs</th>
                                            <th class="text-right" title="Highest Score">HS</th>
                                            <th class="text-right" title="Batting Average">Avg</th>
                                            <th class="text-right" title="No of Balls Faced">BF</th>
                                            <th class="text-right" title="Batting Strike Rate">SR</th>
                                            <th class="text-right" title="No of 100s Scored">100</th>
                                            <th class="text-right" title="No of 200s Scored">200</th>
                                            <th class="text-right" title="No of 50s Scored">50</th>
                                            <th class="text-right" title="No of fours hit">4s</th>
                                            <th class="text-right" title="No of sixes hit">6s</th>
                                        </tr>
                                    </thead>
                                    <tbody>

                                        <tr>
                                            <td class="cb-col-8"><strong>ODI</strong></td>
                                            <td class="cb-plyr-tbody text-right">86</td>
                                            <td class="text-right">145</td>
                                            <td class="text-right">10</td>
                                            <td class="text-right">7240</td>
                                            <td class="text-right">254</td>
                                            <td class="text-right">53.63</td>
                                            <td class="text-right">12552</td>
                                            <td class="text-right">57.68</td>
                                            <td class="text-right">27</td>
                                            <td class="text-right">7</td>
                                            <td class="text-right">22</td>
                                            <td class="text-right">811</td>
                                            <td class="text-right">22</td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                            <div class="cb-plyr-tbl">
                                <div class="cb-font-16 text-bold cb-lst-dom">Bowling Career Summary</div>
                                
                                <table class="table cb-col-30 cb-plyr-thead">
                                    <thead>
                                        <tr class="cb-bg-grey cb-font-12">
                                            <th></th>
                                            <th class="cb-plyr-th text-right" title="Matches Played">M</th>
                                            <th class="text-right" title="No of Innings Bowled">Inn</th>
                                            <th class="text-right" title="No of Balls Bowled">B</th>
                                            <th class="text-right" title="No of Runs Conceded">Runs</th>
                                            <th class="text-right" title="Wickets">Wkts</th>
                                            <th class="text-right" title="Best Bowling in Innings">BBI</th>
                                            <th class="text-right" title="Best Bowling in Match">BBM</th>
                                            <th class="text-right" title="Economy">Econ</th>
                                            <th class="text-right" title="Bowling Average">Avg</th>
                                            <th class="text-right" title="Bowling Strike Rate">SR</th>
                                            <th class="text-right" title="Five Wickets in an Innings">5W</th>
                                            <th class="text-right cb-plyr-stump" title="Ten Wickets in an Match">10W</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        
                                        <tr>
                                            <td class="cb-col-8"><strong>ODI</strong></td>
                                            <td class="cb-plyr-tbody text-right">86</td>
                                            <td class="text-right">11</td>
                                            <td class="text-right">175</td>
                                            <td class="text-right">84</td>
                                            <td class="text-right">0</td>
                                            <td class="text-right">0/0</td>
                                            <td class="text-right">0/0</td>
                                            <td class="text-right">2.88</td>
                                            <td class="text-right">0.0</td>
                                            <td class="text-right">0.0</td>
                                            <td class="text-right">0</td>
                                            <td class="text-right">0</td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </div>
    {% endblock %}
</body>

</html>

Шаблон тега для l oop, где я хочу заменить в <td> значения тега

{% for players in PlayerStructure_details.playerbowlperf.all %}
    {{players.bowl_runs}}
{% endfor %}

I Я пытался разместить эти теги ниже таблицы, но он не показал мне значения в соответствии с моделью.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...