diff --git a/articles/templates/articles/author.html b/articles/templates/articles/author.html
index 2d1796b..f08443d 100644
--- a/articles/templates/articles/author.html
+++ b/articles/templates/articles/author.html
@@ -1,12 +1,15 @@
{% extends 'base.html' %}
+{% block header %}
+
+{% endblock %}
{% block content %}
{{ author.name }}
-
今まで書いた記事
+
今まで書いた記事
@@ -21,6 +24,9 @@ 今まで書いた記事
{{ article.title }}
|
+
+ {{ article.id }}
+ |
{% endfor %}
diff --git a/articles/templates/articles/author_list.html b/articles/templates/articles/author_list.html
new file mode 100644
index 0000000..3f73d63
--- /dev/null
+++ b/articles/templates/articles/author_list.html
@@ -0,0 +1,69 @@
+{% extends 'base.html' %}
+
+{% block content %}
+
+
+
+
+
+
+ | Rank |
+ Name |
+ Rate |
+
+
+
+ {% for author in authors %}
+
+ | {{ forloop.counter0|add:authors.start_index }} |
+
+ {{ author.name }}
+ |
+ {{ author.rate }} |
+
+ {% endfor %}
+
+
+
+
+
+
+
+
+{% endblock %}
diff --git a/articles/views.py b/articles/views.py
index f8d4a16..dc25943 100644
--- a/articles/views.py
+++ b/articles/views.py
@@ -1,18 +1,10 @@
from django.shortcuts import render
-
-# Create your views here.
-
+from django.views.generic import ListView
+from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from .models import Authors
from .models import Articles
-def index(request):
- authors = Authors.objects.order_by('-rate')
- context = {
- 'authors': authors
- }
- return render(request, 'articles/index.html', context)
-
def author(request, author_id):
author = Authors.objects.filter(id=author_id)[0]
articles = Articles.objects.filter(author__id=author_id).order_by('-pub_date')
@@ -23,3 +15,20 @@ def author(request, author_id):
return render(request, 'articles/author.html', context)
+def index(request):
+ authors = Authors.objects.order_by('-rate')
+ paginator = Paginator(authors, 25)
+ page = request.GET.get('page')
+
+ try:
+ extacted_authors = paginator.page(page)
+ except PageNotAnInteger:
+ extacted_authors = paginator.page(1)
+ except EmptyPage:
+ extacted_authors = paginator.page(paginator.num_pages)
+ context = {
+ 'authors': extacted_authors,
+ }
+ return render(request, 'articles/author_list.html', context)
+
+