Skip to content

Commit 33d3e7e

Browse files
committed
2 commit
1 parent aafe114 commit 33d3e7e

File tree

7 files changed

+37
-15
lines changed

7 files changed

+37
-15
lines changed

.idea/dataSources.xml

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

articles/views.py

+9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ def home(request):
1515

1616
def blog(request):
1717
articles = Article.objects.order_by('-id')
18+
s = request.GET.get('s')
19+
if s:
20+
articles = articles.filter(title__icontains=s)
21+
cat = request.GET.get('cat')
22+
if cat:
23+
articles = articles.filter(category__category__exact=cat)
24+
tag = request.GET.get('tag')
25+
if tag:
26+
articles = articles.filter(tags__tag__exact=tag)
1827
ctx = {
1928
'articles': articles,
2029
}

db.sqlite3

0 Bytes
Binary file not shown.

templates/base.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161

6262
{% endblock %}
6363

64-
<footer class="ftco-footer ftco-bg-dark ftco-section", id="footer">
64+
<footer class="ftco-footer ftco-bg-dark ftco-section" id="footer">
6565
<div class="container">
6666
<div class="row mb-5">
6767
<div class="col-md">
@@ -72,7 +72,7 @@ <h2 class="logo"><a href="/">Read<span>it</span>.</a></h2>
7272
<ul class="ftco-footer-social list-unstyled float-md-left float-lft mt-5">
7373
<li class="ftco-animate"><a href="#"><span class="icon-twitter"></span></a></li>
7474
<li class="ftco-animate"><a href="#"><span class="icon-facebook"></span></a></li>
75-
<li class="ftco-animate"><a href="#"><span class="icon-instagram"></span></a></li>
75+
<li class="ftco-animate"><a href="https://www.instagram.com/ravshan.giyosov/"><span class="icon-instagram"></span></a></li>
7676
</ul>
7777
</div>
7878
</div>

templates/blog-single.html

+7-8
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ <h3 class="mb-5">Leave a comment</h3>
9494
</div>
9595
<div class="col-lg-4 sidebar pl-lg-5 ftco-animate">
9696
<div class="sidebar-box">
97-
<form method="post" class="search-form">
98-
{% csrf_token %}
97+
<form method="get" class="search-form" action="/blog/">
9998
<div class="form-group">
10099
<span class="icon icon-search"></span>
101100
<input type="search" name="s" class="form-control" placeholder="Type a keyword and hit enter">
@@ -106,7 +105,7 @@ <h3 class="mb-5">Leave a comment</h3>
106105
<div class="categories">
107106
<h3>Categories</h3>
108107
{% for category in categories %}
109-
<li><a href="#">{{ category }} <span class="ion-ios-arrow-forward"></span></a></li>
108+
<li><a href="/blog/?cat={{ category }}">{{ category }} <span class="ion-ios-arrow-forward"></span></a></li>
110109
{% endfor %}
111110
</div>
112111
</div>
@@ -116,11 +115,11 @@ <h3>Recent Blog</h3>
116115
<div class="block-21 mb-4 d-flex">
117116
<a class="blog-img mr-4" style="background-image: url({{ last_article.image.url }});"></a>
118117
<div class="text">
119-
<h3 class="heading"><a href="#">{{ last_article.title|slice:'100' }}</a></h3>
118+
<h3 class="heading"><a href="{% url 'articles:blog-single' article.id %}">{{ last_article.title|slice:'100' }}</a></h3>
120119
<div class="meta">
121-
<div><a href="#"><span class="icon-calendar"></span> {{ last_article.created_at }}</a></div>
122-
<div><a href="#"><span class="icon-person"></span> {{ last_article.author }}</a></div>
123-
<div><a href="#"><span class="icon-chat"></span> {{ last_article.comment_set.count }}</a></div>
120+
<div><a><span class="icon-calendar"></span> {{ last_article.created_at }}</a></div>
121+
<div><a><span class="icon-person"></span> {{ last_article.author }}</a></div>
122+
<div><a><span class="icon-chat"></span> {{ last_article.comment_set.count }}</a></div>
124123
</div>
125124
</div>
126125
</div>
@@ -130,7 +129,7 @@ <h3 class="heading"><a href="#">{{ last_article.title|slice:'100' }}</a></h3>
130129
<h3>Tag Cloud</h3>
131130
<div class="tagcloud">
132131
{% for tag in tags %}
133-
<a href="#" class="tag-cloud-link">{{ tag }}</a>
132+
<a href="/blog/?tag={{ tag }}" class="tag-cloud-link">{{ tag }}</a>
134133
{% endfor %}
135134
</div>
136135
</div>

templates/blog.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ <h1 class="mb-4 mb-md-0">Readit blog</h1>
4848
<span class="mos">{{ article.created_at|date:'F' }}</span>
4949
</div>
5050
</div>
51-
<h3 class="heading mb-3"><a href="#">{{ article.title }}</a></h3>
51+
<h3 class="heading mb-3"><a href="{% url 'articles:blog-single' article.id %}">{{ article.title }}</a></h3>
5252
<p>{{ article.content|slice:'150'}}</p>
5353
<p><a href="{% url 'articles:blog-single' article.id %}" class="btn-custom"><span class="ion-ios-arrow-round-forward mr-3"></span>Read
5454
more</a></p>

templates/index.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,20 @@ <h1 class="mb-4 mb-md-0">Readit blog</h1>
3838
<div class="case">
3939
<div class="row">
4040
<div class="col-md-6 col-lg-6 col-xl-8 d-flex">
41-
<a href="blog-single.html" class="img w-100 mb-3 mb-md-0"
41+
<a href="{% url 'articles:blog-single' article.id %}" class="img w-100 mb-3 mb-md-0"
4242
style="background-image: url({{ article.image.url }});"></a>
4343
</div>
4444
<div class="col-md-6 col-lg-6 col-xl-4 d-flex">
4545
<div class="text w-100 pl-md-3">
4646
<span class="subheading">{{ article.category }}</span>
47-
<h2><a href="blog-single.html">{{ article.title|slice:'100'}}</a></h2>
47+
<h2><a href="{% url 'articles:blog-single' article.id %}">{{ article.title|slice:'100'}}</a></h2>
4848
<ul class="media-social list-unstyled">
4949
<li class="ftco-animate"><a href="#"><span class="icon-twitter"></span></a></li>
5050
<li class="ftco-animate"><a href="#"><span class="icon-facebook"></span></a></li>
51-
<li class="ftco-animate"><a href="#"><span class="icon-instagram"></span></a></li>
51+
<li class="ftco-animate"><a href="https://www.instagram.com/ravshan.giyosov/"><span class="icon-instagram"></span></a></li>
5252
</ul>
5353
<div class="meta">
54-
<p class="mb-0"><a href="#">{{ article.created_at }}</a></p>
54+
<p class="mb-0"><a>{{ article.created_at }}</a></p>
5555
</div>
5656
</div>
5757
</div>

0 commit comments

Comments
 (0)