diff --git a/application/templates/blog_search_list_view.html b/application/templates/blog_search_list_view.html index f8adebd..a54fb10 100644 --- a/application/templates/blog_search_list_view.html +++ b/application/templates/blog_search_list_view.html @@ -1,9 +1,12 @@ {% extends "base.html" %} {% block content %} - -
+{% load taggit_templatetags2_tags %} +{% get_taglist as tags for 'application.post' %} +
diff --git a/application/templates/post_detail.html b/application/templates/post_detail.html index 19bdf32..4b8512f 100644 --- a/application/templates/post_detail.html +++ b/application/templates/post_detail.html @@ -6,8 +6,7 @@
{% else %} Publish - {% endif %} - {% if user.is_staff and user == post.author %} + {% endif %} {% if user.is_staff and user == post.author %} Edit @@ -17,7 +16,13 @@ {% endif %}

{{ post.title }}

{{ post.text|linebreaksbr }}

-

{{ post.tag }}

- +

+ {% for tag in post.tags.all %} + {{ tag.name }}, + {% endfor %} +

+

+ Autor: {{ post.author }} +

{% endblock %} \ No newline at end of file diff --git a/application/templates/post_list.html b/application/templates/post_list.html index 32fee5c..cd0c6b7 100644 --- a/application/templates/post_list.html +++ b/application/templates/post_list.html @@ -18,14 +18,5 @@ {% endfor %} -{% include "taggit_templatetags2/tagcanvas_include_js_static.html" %} - -
- -
{% endblock %} \ No newline at end of file diff --git a/application/views.py b/application/views.py index ad58749..5378791 100644 --- a/application/views.py +++ b/application/views.py @@ -110,17 +110,15 @@ def post_remove(request, pk): @login_required def student_page(request): - return render(request, 'student_page.html', {}) + q = request.GET.get('q') + query = Q() + for word in q or []: + query = query | Q(tags__name__icontains=word) + result = Post.objects.filter(query) + return render(request, 'blog_search_list_view.html', {'result':result}) + -def blog_search_list_view(post_list, self): - result = super(post_list, self).get_queryset() - query = self.request.GET.get('q') - if query: - query_list = query.split() - result = result.filter( - reduce(operator.and_, - (Q(title__icontains=q) for q in query_list)) | - reduce(operator.and_, - (Q(content__icontains=q) for q in query_list)) - ) - return result \ No newline at end of file + +def blog_search_list_view(request): + + return render(request, 'blog_search_list_view.html', {})