by clicking on tags, all the posts with this tag showing up

This commit is contained in:
Esther Kleinhenz
2018-09-02 11:58:21 +02:00
parent 6cdbec7315
commit 768a3e4a2e
4 changed files with 42 additions and 15 deletions
+6 -8
View File
@@ -1,4 +1,6 @@
{% extends 'base.html' %} {% block content %} {% for post in posts %} {% load taggit_templatetags2_tags %}
{% extends 'base.html' %} {% block content %}
{% if tag %} Posts tagged with "{{ tag.name }}" {% endif %}
{% for post in posts %} {% load taggit_templatetags2_tags %}
<div class="post">
<div class="date">
{{ post.published_date }}
@@ -7,15 +9,11 @@
<a href="{% url 'post_detail' pk=post.pk %}">{{ post.title }}</a>
</h1>
<p>{{ post.text|linebreaks }}</p>
<p>
{% for tag in post.tags.all %}
<a href="">{{ tag.name }}, </a>
{% endfor %}
</p>
<p>
Tags: {% for tag in post.tags.all %}
<a href="{% url 'post_list_by_tag' tag.slug %}">{{ tag.name }}</a>
{% if not forloop.last %}, {% endif %} {% endfor %} <p>
{{ post.author }}
</p>
</div>
{% endfor %}
</div>
+15 -3
View File
@@ -1,5 +1,18 @@
{% extends "base.html" %} {% block content %}
{% extends "base.html" %} {% block content %} {% load taggit_templatetags2_tags %} {% get_taglist as tags for 'application.post'%}
<div id="">
<ul>
{% for tag in tags %}
<li>{{tag}}
<a class="btn btn-outline-dark" href="{% url 'tag_remove' %}">
<span class="glyphicon glyphicon-remove">Remove</span>
</a>
</li>
{{ result }} {% endfor %}
</ul>
</div>
<div>
</div>
<form id="searchform" action="{% url 'blog_search_list_view' %}" method="get" accept-charset="utf-8">
<button class="searchbutton" type="submit">
<i class="fa fa-search"></i>
@@ -12,8 +25,7 @@
</div>
<form class="post-form" method="post">
{% csrf_token %}
{{form.as_p}}
{% csrf_token %} {{form.as_p}}
<button type="submit" class="save btn btn-outline-dark">Save</button>
</form>
{% endblock %}