zoukankan      html  css  js  c++  java
  • 分页显示的制作流程


    1.在app下新建名为templatetags的python包,并在其中新建mytags.py文件(此文件用于书写函数)

    2.在新建的mytags.py文件中写入以下两行代码:
      from django import template
      register=template.Library()

      然后定义函数:
      def pagination(total,current)
        return {'total':total,'current':current}

      函数定义上方写装饰器:@register.inclusion_tag('pagination.html')

    3.书写pagination.html模板
      将母版中的分页部分取出来,修改
      {% for num in total %}
      {% if num == current %}
      <li class="active"><a href="#">{{ num }}</a></li>
      {% else %}
      <li><a href="#">{{ num }}</a></li>
      {% endif %}
      {% endfor %}
    4.使用
      {% load mytags %}
      {% 函数名 参数1 参数2 %}

  • 相关阅读:
    动态规划
    关键路径
    拓扑排序
    最小生成树
    Floyd 多源最短路径
    SPFA算法
    Bellman_Ford算法(负环的单源路径)
    Dijkstra算法
    fill和memset的区别
    Codeforces Round #655 (Div. 2) 题解
  • 原文地址:https://www.cnblogs.com/wdbgqq/p/9699851.html
Copyright © 2011-2022 走看看