在数据库中调用列。我正在为python开发Django

2024-04-18 18:23:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我目前被困在程序中,它将输出表中所有值为category_id == 1的post。我似乎不能调用上述函数,你们能帮忙吗?谢谢,我们将不胜感激

{% for knowledgepost in kposts %}
  <article class="media content-section">
    <div class="media-body">
      <div class="article-metadata">
        <a class="mr-2" href="#">{{ knowledgepost.author }}</a>
          <small class="text-muted">{{ knowledgepost.date_posted|date:"F d, Y" }}</small>
      </div>
            <h3><a class="article-title" href="{% url 'knowledge-detail' knowledgepost.id %}">{{ knowledgepost.title }}</a></h3>
++++++++ the line of code should be here+++++++++++
            <p class="article-content">{{ knowledgepost.content|safe|truncatewords:"50"|linebreaks }}</p>
          </div>
        </article>

我希望输出能够调用数据库中的列


Tags: 程序dividdatetitlearticlecontentmedia