2016-09-15 31 views
2

我顯示了一些使用flask-paginate的RSS提要,並且分頁工作正常,但pagination.links的樣式不正確,它看起來像一個項目符號列表。有計算器上類似的問題和回答說,包括用於引導CSS和我沒有,但還是造型保持不變flask-paginate pagination.links樣式問題

下面是兩個模板

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) 

回答

3

好吧,這是非常愚蠢的我,我得到它通過指定css_framework參數「bootstrap3」,而初始化分頁對象工作,文檔說引導是默認的,但好像你需要這樣明確的指定

,該變化是

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

輝煌,我永遠也不會找到這個特別令人困惑的是,github上的例子(https://github.com/lixxu/flask-paginate/tree/master/example)對bootstrap3起作用,但*不包括'css_framework ='bootstrap3 「'。 –