저는 Q를 건축 중입니다 & 토픽이 포함 된 포럼을 포함한 카테고리가있는 스타일 커뮤니티이며 각 토픽에 게시물이 있습니다. 방문 페이지에서 모든 카테고리에서 인기 주제를 원하고 카테고리 내에서 인기있는 주제를 해당 카테고리에서 원합니다. 템플릿 필터를 정의했지만 카테고리 나 집 수준에서는 아무 것도 표시하지 않습니다. 포럼 수준에서 일종의 작업을 수행 할 수 있습니다. 즉 특정 포럼 내부에서 해당 포럼의 모든 주제를 가져올 수 있습니다. 카테고리 안에는 현재 해당 카테고리의 각 포럼에서 모든 주제를 가져와야합니다. 현재는 모든 주제 목록이 아닌 해당 카테고리의 포럼 목록 만 반환합니다. 집 수준에서는 모든 카테고리에서 주제 목록을 반환하고 포럼을 포함하고 있지만 아무 것도 얻을 수 없습니다.모델 쿼리가 제대로 작동하지 않는 이유는 무엇입니까?
누군가 나에게 무슨 일이 일어나는지 알아낼 수 있습니까? 감사합니다
내 TOPICSFORALL.HTML :
{% block card_body %}
{% for topic in topic_list %}
{% include "subjectcard.html" with topic=topic %}
{% endfor %}
{% endblock %}
내 SUBJECTCARD.HTML :
{% block card_body %}
{% for topic in topic_list %}
{% include "subjectcard.html" with topic=topic %}
{% endfor %}
{% endblock %}
내 SITE_BASE.HTML :
{% extends "theme_bootstrap/base.html" %}
{% load i18n pybb_tags topicsbycat topicsbyforum %}
{% load static %}
{% catindexlist as catindexlisted %}
{% topicsbyall as topicsbyallcatnforum %}
...
{% block body %}
<!-- Main hero unit for a primary marketing message or call to action -->
<div class="col-xs-2 col-sm-3 col-md-2 col-lg-2" style="border-right:solid;text-align:right;height:99%;padding:0 0 0 0px;" id="sidebar">{% include "categoryindex.html" %}</div>
<div class="col-xs-10 col-xs-offset-1 col-sm-10 col-sm-offset-3 col-md-10 col-md-offset-2 col-lg-10 col-lg-offset-2" id="homebread">{% include "breadcrumbbt.html" %}</div>
{% if category %}
<div class="col-xs-10 col-xs-offset-1 col-sm-10 col-sm-offset-3 col-md-10 col-md-offset-2 col-lg-10 col-lg-offset-2" style="height:auto;padding-bottom:10px;text-align:center;">{% include "topicstyleforumindex.html" %}</div>
<div class="col-xs-10 col-xs-offset-1 col-sm-10 col-sm-offset-3 col-md-10 col-md-offset-2 col-lg-10 col-lg-offset-2" style="height:auto;padding-bottom:10px;text-align:center;">{% include "topicsforall.html" with topic_list=category|topicsbycat %}</div>
{% elif forum %}
<div class="col-xs-10 col-xs-offset-1 col-sm-10 col-sm-offset-3 col-md-10 col-md-offset-2 col-lg-10 col-lg-offset-2" style="height:auto;padding-bottom:10px;text-align:center;">{% include "topicindex.html" %}</div>
<div class="col-xs-10 col-xs-offset-1 col-sm-10 col-sm-offset-3 col-md-10 col-md-offset-2 col-lg-10 col-lg-offset-2" style="height:auto;padding-bottom:10px;text-align:center;">{% include "topicsforall.html" with topic_list=forum|topicsbyforum %}</div>
{% elif topic %}
<div class="main-block col-xs-6 col-xs-offset-1 col-sm-6 col-sm-offset-3 col-md-6 col-md-offset-2 col-lg-6 col-lg-offset-2" id="content" style="height:80%;">{% include 'pybb/topic.html' %}</div>
{% else %}
<div class="col-xs-10 col-xs-offset-1 col-sm-10 col-sm-offset-3 col-md-10 col-md-offset-2 col-lg-10 col-lg-offset-2" style="height:auto;padding-bottom:10px;text-align:center;">{% include "topicstyleforumindex.html" %}</div>
<div class="col-xs-10 col-xs-offset-1 col-sm-10 col-sm-offset-3 col-md-10 col-md-offset-2 col-lg-10 col-lg-offset-2" style="height:auto;padding-bottom:10px;text-align:center;">{% include "topicsforall.html" with topic_list=topicsbyallcatnforum %}</div>
{% endif %}
{% endblock %}
내 PYBB_TAGS.PY :
@register.assignment_tag
def topicsbyall():
topic_list = Topic.objects.all().order_by('-updated', '-created')
return topic_list
,210
내 TOPICSBYFORUM.PY : 레지스터 = template.Library()
@ register.filter
def topicsbyforum(forum):
topic_list = Topic.objects.filter(forum=forum).order_by('post_count','views','-updated')
return topic_list
내 TOPICSBYCAT.PY :
register = template.Library()
@register.filter
def topicsbycat(category):
topic_list = []
catforum = Forum.objects.filter(category=category).order_by('topic_count','post_count')
for forum in catforum:
forumtopics = Topic.objects.filter(forum=forum).order_by('post_count','views','-updated')
topic_list.append(forumtopics)
return topic_list