Right now I have a list view that displays 10 posts per page:
The urls would be something like this:
www.example.com/posts/1 (First page with 10 results)
www.example.com/posts/2 (Next page with 10 results)
and my urls.py looks something like this:
path('posts/<int:page>', PostList.as_view(), name='post-list'),
I want to be able to have the first page of posts also visible when there is no number, for example:
www.example.com/posts (First page with 10 results)
The only way that I have been able to solve this is by adding another line in the urls.py that points to the same view and that has the same name.
path('posts', PostList.as_view(), name='post-list'),
path('posts/<int:page>', PostList.as_view(), name='post-list'),
Is this the appropriate way of doing this or is there a better way?
Many thanks!