意见
class ThreadListView(ListView):
model = Thread
template_name = 'forums/thread.html'
def get_context_data(self, **kwargs):
# Call the base implementation first to get a context
context = super().get_context_data(**kwargs)
# Add in a QuerySet of the Thread & Replies
context['thread'] = Thread.objects.get(pk=self.kwargs['pk'])
context['reply'] = Thread.objects.get(pk=self.kwargs['pk']).replies.all()
return context
HTML
{% extends 'forums/base.html' %}
{% block title %} Forum - {{ thread.title }} {% endblock title %}
{% block content %}
<!--Thread real-->
<table class="table table-hover">
<thead>
<tr class="table-primary">
<th class="col-2"><a href="{% url 'threadview' thread.id %}"> {{ thread.title }}</a></th>
<th scope="col-10" id="content-col"></th>
</tr>
</thead>
<tbody>
<!--Thread Author and Content-->
<tr class="table-info">
<td class="border-right text-center">
<span>
<img class="rounded-circle" style="height: 100px;width: 100px;"
src="{{ thread.author.profile.image.url }}"> <br />
Username: <a href="#">{{ thread.author.username|capfirst }}</a> <br />
Ranks: 
<!--Ranks Go Here--> <br />
<hr>
Posts: 
<!--Posts Go Here--> <br />
Badges: 
<!--Badges Go Here--> <br />
<hr>
Date Joined: {{thread.author.date_joined| date:'Y-m-d'}} <br />
</span>
</td>
{% endblock content %}
我想对线程 ListView 进行分页。
Thread ListView 显示 Thread,然后显示该线程上的回复。
我希望能够将所有内容分成页面。
例如,线程以 Thread 帖子和 10 个回复开始,然后要查看一些较新的回复,您可以单击下一页。
慕村9548890
相关分类