如何设置Bootstrap主题为django无尽的分页? [英] How to set Bootstrap theme for django-endless-pagination?

查看:138
本文介绍了如何设置Bootstrap主题为django无尽的分页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始Django和前端开发。我想使用Bootstrap主题来构建一些分页的Django应用程序。我发现 django-endless-pagination 对于分页是非常有用的。要启动Bootstrap主题,我尝试过 django-endless- pagination-bootstrap-theme



我有我的 views.py 刚刚返回的条目列表将显示在 display.html 中,其编码为:

 <! - 最新编译和最小化的CSS  - > 
< link rel =stylesheethref =https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css>

{%load endless%}

{%paginate entries%}

{%条目中的条目%}
< p> {{entry.value}}< / p>
{%endfor%}

< div class =pagination>
{%show_pages%}
< / div>

然而,我的分页样式(如图1所示)与 django-endless-pagination-bootstrap-theme的网站 (如图2所示)。



1





2





我可以知道我的例子中有什么问题吗?



谢谢。

解决方案

您必须包含在您的html文件中(正文结束标记之前) .js 文件。例如:

 < script src =https://ajax.googleapis.com/ajax/libs/jquery/1.11 0.1 / jquery.min.js>< /脚本> 
< script src =http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js>< / script>

更新



也许,而不是

 < div class =pagination> 
{%show_pages%}
< / div>

你可以这样使用引导3.3.4

  {%get_pages%} 
< ul class =pagination>
{%页面页面%}
< li>< a href ={{page.url}}> {{page.number}}< / a> /立GT;
{%endfor%}
< / ul>


I'm new to Django and front-end development. I would like to build some Django app with pagination, using the Bootstrap theme. I found django-endless-pagination is quite useful for pagination. To have the Bootstrap theme, I tried django-endless-pagination-bootstrap-theme.

I have my views.py just returned a list of entries to be shown in display.html which is coded as:

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">

{% load endless %}

{% paginate entries %}

{% for entry in entries %}
    <p>{{ entry.value }}</p>
{% endfor %}

<div class="pagination">
{% show_pages %}
</div>

However, the pagination style I have (shown in Fig. 1) is quite different from that shown in the website of django-endless-pagination-bootstrap-theme (copied as in Fig. 2).

Fig. 1

Fig. 2

May I know what the problems are in my example?

Thank you.

解决方案

You have to include in your html file (before the body closing tag) the .js files too. For ex:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>

UPDATE

Maybe, instead of

<div class="pagination">
{% show_pages %}
</div>

you could so something like this using bootstrap 3.3.4

{% get_pages %}
<ul class="pagination">
{% for page in pages %}
    <li><a href="{{ page.url }}">{{ page.number }}</a></li>
{% endfor %}
</ul>

这篇关于如何设置Bootstrap主题为django无尽的分页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆