2👍
You don’t need to, the next and previous are both things you can pass through as extra context for which there is a get_context_data
method on all Generic Views
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['next_post'] = my_next_post
context['prev_post'] = my_prev_post
return context
You’ll then be able to use next_post
and prev_post
in your template.
See Getting next and previous objects in Django for at least one way of retrieving the next and previous posts.
-1👍
I think you’ll have to write your own view for that. You’re searching for pagination and django offers a good functionality for that (https://docs.djangoproject.com/en/1.10/topics/pagination/).
Source:stackexchange.com