【问题标题】:flask-paginate pagination.links styling issueflask-paginate pagination.links 样式问题
【发布时间】:2017-01-23 11:47:13
【问题描述】:

我正在使用 flask-paginate 显示一些 rss 提要,并且分页工作正常,但 pagination.links 的样式不正确,它看起来像一个项目符号列表。在 stackoverflow 上有一个类似的问题,答案是包含 CSS for bootstrap,我做到了,但样式仍然保持不变

下面是两个模板

base.html 头部

<head>
    <title>{% block title %}{% endblock %}</title>

    <link rel="stylesheet" href="{{ url_for('static', filename='stylesheets/style.css') }}">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

    <link rel="stylesheet" href="{{ url_for('static', filename='stylesheets/bootstrap-social.css') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='font-awesome-4.6.3/css/font-awesome.css') }}">

    <!--flask-paginate stylsheet -->
    <!--<link rel="stylesheet" href="{{ url_for('static', filename='stylesheets/web.css') }}">-->

    <!-- Dependencies for chosen jquery plugin -->

    <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
    <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>

    <!-- chosen jquery plugin -->
    <script src="{{ url_for('static', filename='chosen/chosen.jquery.js') }}"></script>
    <link rel="stylesheet" href="{{ url_for('static', filename='chosen/chosen.css') }}">

    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

</head>

index.html

{{ pagination.info }}
{{ pagination.links }}
{% for e in entries_sorted %}

        <div class="row"> 
        <div class="col-md-offset-3 col-md-6 feed_item">
            <h1><a href="{{ e.link }}">{{ e.title }}</a></h1>
            <h5>Published on: {{ e.published }}</h5>
            {% for content in e.content %}
                {{ content.value|safe }}
                </div>
                </div>
            {% else %}
                 <p>{{ e.summary_detail.value|safe }}</p>
                </div>
                </div>
            {% endfor %}
{% endfor %}
{{ pagination.links }}

views.py 我在其中传递分页对象

i = (page-1)*ITEMS_PER_PAGE
entries = entries_sorted[i:i+5]
#entries_paginated = entries_sorted.paginate(page,ITEMS_PER_PAGE,False)
pagination = Pagination(page=page, total=len(entries_sorted),record_name='Feeds',per_page=ITEMS_PER_PAGE)

return render_template('index.html',title='Home Page',entries_sorted=entries,pagination=pagination)

【问题讨论】:

    标签: twitter-bootstrap flask pagination


    【解决方案1】:

    只是为了投入我的 0.02 美元。如果接受的答案仍然不适合您,请检查您的引导程序版本。

    就我而言,我需要将我的 css_framework 设置为“bootstrap4”。

    【讨论】:

      【解决方案2】:

      好吧,这对我来说很愚蠢,我通过在初始化分页对象时将 css_framework 参数指定为“bootstrap3”来使其工作,文档说 bootstrap 是默认设置,但似乎您需要明确指定它

      所以,变化是

      pagination = Pagination(page=page,per_page=ITEMS_PER_PAGE,total=len(entries_sorted),record_name='Feeds',css_framework='bootstrap3')
      

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-02-24
      • 2020-11-16
      • 2017-09-26
      • 1970-01-01
      • 1970-01-01
      • 2012-11-09
      • 2013-04-19
      • 1970-01-01
      相关资源
      最近更新 更多