from django.views.generic import ListView
class PostListView(ListView):
queryset = Post.published.all()
context_object_name = 'posts'
paginate_by = 1
template_name = 'blog/post/list.html'
from .views import (
...
PostListView,
)
urlpatterns = [
...
url(r'^$', PostListView.as_view(), name='post_list'),
]
{% for post in posts %}
{{ post.get_absolute_url }}
{{ post.title }}
{{ post.author.username }}
{{ post.publish }}
{{ post.content }}
{% endfor %}
{% include 'pagination.html' with page=page_obj %}