From 8117e9b8779eeba45399162be03bc2aab7580ca7 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 8 Sep 2010 00:46:04 -0500 Subject: Paginate the news list view This view was getting huge with ~500 items on it, and most people are not really interested in seeing every single news item. Use the drop in pagination and add some controls that still allow browsing to any page of the list. Signed-off-by: Dan McGee --- media/archweb.css | 4 ++++ news/views.py | 1 + templates/news/list.html | 4 ++++ templates/news/paginator.html | 22 ++++++++++++++++++++++ 4 files changed, 31 insertions(+) create mode 100644 templates/news/paginator.html diff --git a/media/archweb.css b/media/archweb.css index f417e5ee..e662c670 100644 --- a/media/archweb.css +++ b/media/archweb.css @@ -142,6 +142,10 @@ div.widget { margin-bottom: 1.5em; } #artwork img.inverted { background: #333; padding: 0; } #artwork div.imagelist img { display: inline; margin: 0.75em; } +/* news: article list */ +.news-nav { float: right; margin-top: -2.2em; } +.news-nav .prev, .news-nav .next { margin-left: 1em; margin-right: 1em; } + /* news: article pages */ div.news-article .article-info { margin: 0; color: #999; } diff --git a/news/views.py b/news/views.py index 37472115..cc169819 100644 --- a/news/views.py +++ b/news/views.py @@ -19,6 +19,7 @@ def view(request, newsid): def list(request): return list_detail.object_list(request, News.objects.all().select_related('author').defer('content'), + paginate_by=50, template_name="news/list.html", template_object_name="news") diff --git a/templates/news/list.html b/templates/news/list.html index cadc24a2..258456a5 100644 --- a/templates/news/list.html +++ b/templates/news/list.html @@ -12,6 +12,8 @@ {% endif %} + {% include "news/paginator.html" %} + @@ -45,5 +47,7 @@
+ {% include "news/paginator.html" %} + {% endblock %} diff --git a/templates/news/paginator.html b/templates/news/paginator.html new file mode 100644 index 00000000..fbd0546b --- /dev/null +++ b/templates/news/paginator.html @@ -0,0 +1,22 @@ +{% if is_paginated %} + +{% endif %} -- cgit v1.2.3-55-g3dc8