所以我尝试安装django-el-pagination,但显然,它不想加载到我的网页上。每个包都已安装但不会显示。这是我做的:
def index(request):
course_list = Course.objects.all()
page = request.GET.get('page', 1)
paginator = Paginator(course_list, 1)
try:
courses1 = paginator.page(page)
except PageNotAnInteger:
courses1 = paginator.page(1)
except EmptyPage:
courses1 = paginator.page(paginator.num_pages)
context = {
'courses1': courses1,
'courses': Course.objects.all(),
'faculties': Faculty.objects.all(),
'departments': Department.objects.all(),
'studies': StudyProgramme.objects.all(),
'teachers': Teacher.objects.all()
}
return render(request, 'courses/index.html', context)
<div id="crs">
<h3>All courses</h3>
<ul>
{% paginate courses1 %}
{% for course in courses1 %}
<li><a href={{ course.slug }}>{{ course.name }}</a></li>
{% endfor %}
{% show_pages %}
</ul>
</div>
答案 0 :(得分:0)
尝试使用课程%}将{%分班的课程1%}更改为{%分班的课程1}。或{{%使用“课程”%}的分页课程