【问题标题】:How to have next and previous links on a webpage in django:如何在 django 的网页上拥有下一个和上一个链接:
【发布时间】:2015-06-09 05:49:55
【问题描述】:

我正在使用 django Python 模板来写博客。 对于这个特定的博客,我有两个不同的框架。 要在左侧框架上加载链接,我编写了以下代码:

 {% for post in posts %}

    <div class="post">

        <ul style="padding: 1px;">


            <li style="border-bottom: dotted 1px; padding: 1px;"><a id="myid{{forloop.counter}}" href="{{post.get_absolute_url}}" Target="post" >
                {{post.title}}

            </a></li>

        </ul>

        <p>

        </p>
    </div>
    {% endfor %}

在右侧加载特定的 POST,使用以下代码:

 <h1> {{post.description}} </h1>


    {{post.content|safe|linebreaks}}

我想在我的博客上添加下一个和上一个链接。如何在 django 模板中进行操作。我的博客上传到 matmock.pythonanywhere.com

【问题讨论】:

    标签: html django templates


    【解决方案1】:

    您要查找的内容称为分页。这是tutorial 供您参考。

    【讨论】:

    • 我已经阅读了教程,但由于缺乏深入的知识,我无法理解。但我已经使用 javascript 实现了下一个和上一个按钮。 :) @Abhishek 谢谢..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多