我在燒瓶中建立一個網站,我想設置一個從最新到最舊的博客文章的文章順序。帖子在數(shù)據庫中,我在其中創(chuàng)建了一個 id,其中最舊的帖子的 id = 0,最新的帖子 = 1,依此類推。原來在jinja html中,post是從0到1開始的,想反了。我正在搜索只是為每行設置一個 ID,但我需要幫助來建立此順序,謝謝您的關注。這是我的 jinja html 頁面的代碼{% extends "layout.html" %}{% block content %} {% for post in posts %} <article class="media content-section"> <div class="media-body"> <div class="article-metadata"> <a class="mr-2" href="/{{post.url}}">{{ post.title }} {{post.id}}</a> <small class="text-muted">{{ post.author }}</small> </div> <div id="description_2" class="article-content"><a>{{ post.short_description }}</a></div> </div> {%endif%} </article> {% endfor %}{% endblock content %}
如何設置記錄優(yōu)先級以顯示 HTML?
慕碼人2483693
2022-06-14 10:04:14