1
votes

I'm building a Blog in Django (using Generic Views) and I use the same template for both my date based and list detail views. I'm trying to setup pagination, but I want to do so with URL patterns rather than using an ugly ?page=1 url suffix.

The problem is in the actual html template, I cannot find a way to determine which view was used to render the page, so while I have access to all the pagination stuff, I have no way to generate the appropriate URL.

In other words, if the view was rendered by my archive_month(request, month, year, page=0) view, I would need to structure the URL for the next and previous pages as /blog/dec/2009/PageX/, versus the blog index, which would mean the URL would be /blog/pageX/.

1
You may think that ?page=x is "ugly", but I would say it is better practice. A different page is not a different resource, it's a different view of the same resource. Thus it should have the same URL, and be distinguished by GET parameter.Carl Meyer
That's actually a great point. If you post it as a answer I'd except it.KeyboardInterrupt

1 Answers

1
votes

Well I just realized that date_based generic views don't support pagination, so problem solved.