<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>play</title>
</head>
<body>
<h1>Welcome to oldboy shopping mall,play center ..</h1>
<ul>{% for user in users %}
    {#% if user.username == "alex2" %#}
    {#% if forloop.counter > 2 %#}
    {%  if forloop.counter|divisibleby:“2” %}  # 判断如果循环索引奇偶行数
        <li style="background-color: red">username:{{ user.username }},name:{{user.name }}</li>
    {% else %}
        <li style="background-color: green">username:{{ user.username }},name:{{user.name }}</li>
    {% endif %}
{% endfor %}
</ul>

</body>
</html>

 实现如下:

django模板 实现奇偶分行

 

相关文章:

  • 2021-05-27
  • 2021-10-20
  • 2022-12-23
  • 2022-12-23
  • 2021-04-24
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-17
  • 2021-09-27
  • 2022-12-23
  • 2021-10-12
相关资源
相似解决方案