8000 close #22 · moktadirul-raju/DjangoBlog@925918b · GitHub
[go: up one dir, main page]

Skip to content

Commit 925918b

Browse files
committed
close #22
1 parent 1cee422 commit 925918b

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

blog/__pycache__/views.cpython-37.pyc

169 Bytes
Binary file not shown.

blog/views.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ def archeive_posts_by_date(request, year, month, day):
111111
def search_view(request):
112112
if request.method == 'GET' :
113113
search_query = request.GET.get('search_box')
114-
post_list = Post.objects.filter(title__contains=search_query ) | Post.objects.filter(content__contains=search_query )
115-
# | Category.objects.filter(text__contains=search_query ) | Tag.objects.filter(text__contains=search_query )
114+
tag_list = Tag.objects.filter(text__contains=search_query)
115+
cat_list = Category.objects.filter(text__contains=search_query)
116+
post_list = Post.objects.filter(title__contains=search_query ).distinct() | Post.objects.filter(content__contains=search_query ).distinct() | Post.objects.filter(tag__id__in=tag_list).distinct() | Post.objects.filter(category__id__in=cat_list).distinct()
116117

117118
paginator = Paginator(post_list, 5) # Show 5 posts per page
118119
page = request.GET.get('page')

templates/blog/single.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ <h2>{{post.title}}</h2>
3232
<p><b>Categories:</b>
3333
{% for category in post_categories %}
3434
{% if forloop.last %}
35-
<a href="/blog/tag/{{ category.text }}" />{{ category.text }}</a>
35+
<a href="/blog/category/{{ category.text }}" />{{ category.text }}</a>
3636
{% else %}
37-
<a href="/blog/tag/{{ category.text }}" />{{ category.text }}</a>,
37+
<a href="/blog/category/{{ category.text }}" />{{ category.text }}</a>,
3838
{% endif %}
3939
{% endfor %}
4040
</p>

0 commit comments

Comments
 (0)
0