#views.py
class IndexView(generic.ListView):
template_name = 'index.html'
context_object_name = 'home_list'
queryset = Song.objects.all()
paginate_by = 1
def get_context_data(self, **kwargs):
context = super(IndexView, self).get_context_data(**kwargs)
context['all_artists']=Artist.objects.all()
context['all_songs']=Song.objects.all()
context['all_albums']=Album.objects.all()
return context
base.html文件(这是由index.html的延长):
#base.html
{% block content %}{% endblock %}
{% block pagination %}
{% if is_paginated %}
{% if page_obj.has_previous %}
{% endif %}
Page {{page_obj.number}} of {{page_obj.paginator.num_pages }}
{% if page_obj.has_next %}
{% endif %}
{% endif %}
{% endblock %}
而且我的index.html:
{% extends 'base_generic.html' %}
{% block title %}
Listen to songs {% endblock %}{% block content %}
Best Songs
{% for song in all_songs %}
{% endfor %}
Best Albums
{% for album in all_albums %}
{% endfor %}
{% endblock %}
所以当我编译这个,我得到这个窗口: Image here 但在所有页面,它保持不变。我想要显示1歌曲per page.Help家伙!!!! :]:]:]