File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -9,4 +9,52 @@ <h1 class="fw-bolder">shahriaarrr Blog</h1>
99 < h5 class ="text-muted "> Write about everything that i liked</ h5 >
1010 </ div >
1111 </ div >
12+
13+ {% for object in object_list %}
14+ < div class ="row ">
15+ < div class ="col-md-6 col-12 mx-md-auto mx-3 mt-5 md-5 ">
16+ < h3 class ="fw-bold "> {{ object.title }}</ h3 >
17+ < p class ="text-muted "> {{ object.date }}</ p >
18+ < p class ="text-muted "> By {{ object.author.username }}</ p >
19+ {% if object.likes.count == 1 %}
20+ < p class ="text-muted "> {{ object.likes.count }} person liked</ p >
21+ {% else %}
22+ < p class ="text-muted "> {{ object.likes.count }} people liked</ p >
23+ {% endif %}
24+ < div class ="my-3 ">
25+ {{ object.content | truncatewords_html:50 | safe }}
26+ </ div >
27+ < a href ="# "> Read more</ a >
28+ </ div >
29+ </ div >
30+ {% endfor %}
31+
32+ < nav >
33+ < ul class ="pagination ">
34+ < div class ="mx-auto d-flex flex-row mt-5 ">
35+ {% if page_obj.has_previous %}
36+ < li class ="page-item ">
37+ < a class ="page-link " href ="?page=1 "> « First
38+ </ a >
39+ </ li >
40+
41+ < li class ="page-item ">
42+ < a class ="page-link " href ="?page={{ page_obj.previous_page_number }} "> Previous</ a >
43+ </ li >
44+ {% endif %}
45+
46+ < li class ="page-item ">
47+ < a class ="page-link " href ="# "> Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}.</ a >
48+ </ li >
49+ {% if page_obj.has_next %}
50+ < li class ="page-item ">
51+ < a class ="page-link " href ="?page={{ page_obj.next_page_number }} "> Next</ a >
52+ </ li >
53+ < li class ="page-item ">
54+ < a class ="page-link " href ="?page={{ page_obj.paginator.num_pages }} "> Last »</ a >
55+ </ li >
56+ {% endif %}
57+ </ div >
58+ </ ul >
59+ </ nav >
1260{% endblock %}
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ class Index(ListView):
99 model = Article
1010 queryset = Article .objects .all ().order_by ("-date" )
1111 template_name = 'blog/home.html'
12+ paginate_by = 1
1213
1314
1415class About (View ):
You can’t perform that action at this time.
0 commit comments