Просмотры
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>
<td>{{ thread.content }}</td>
</tr>
<!--Reply Author and Content-->
{% for rply in reply %}
<tr class="table-secondary">
<td class="border-right text-center">
<span>
<img class="rounded-circle" style="height: 100px;width: 100px;"
src="{{ rply.author.profile.image.url }}"> <br />
Username: <a href="#">{{ rply.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>
<td>
<p>{{ rply.content }}</p>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock content %}
Я хочу разбить на страницы представления списка.
Просмотр списка показывает поток изатем он показывает ответы, которые находятся в этой теме.
Я хочу иметь возможность разбить весь контент на страницы.
Например, тема начинается с сообщения в теме и 10ответы, а затем просмотреть некоторые новые ответы, вы сможете нажать на следующей странице.