Browse Source

shows tags of each post in post_list

newsletter
Esther Kleinhenz 6 years ago
parent
commit
42d69dfe44

+ 2
- 0
application/templates/post_detail.html View File

@@ -17,5 +17,7 @@
{% endif %}
<h1>{{ post.title }}</h1>
<p>{{ post.text|linebreaksbr }}</p>
<p>{{ post.tag }}</p>

</div>
{% endblock %}

+ 5
- 0
application/templates/post_list.html View File

@@ -7,5 +7,10 @@
<a href="{% url 'post_detail' pk=post.pk %}">{{ post.title }}</a>
</h1>
<p>{{ post.text|linebreaks }}</p>
{% for tag in post.tags.all %}
<p>{{ tag.name }}</p>
{% endfor %}


</div>
{% endfor %} {% endblock %}

+ 0
- 2
application/templates/student_page.html View File

@@ -6,8 +6,6 @@
</button>
<input class="searchfield" id="searchbox" name="q" type="text" placeholder="Search">
</form>
<div>{{Post.objects.filter(tags__name__in= ["hi"])}}
</div>
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover">
</table>

+ 1
- 1
application/urls.py View File

@@ -4,6 +4,7 @@ from . import views
urlpatterns = [
url(r'^$', views.post_list, name='post_list'),
url(r'^student/', views.student_page, name='student_page'),
url(r'^search/', views.blog_search_list_view, name='blog_search_list_view'),
url(r'^post/(?P<pk>\d+)/$', views.post_detail, name='post_detail'),
url(r'^post/new/$', views.post_new, name='post_new'),
url(r'^post/(?P<pk>\d+)/edit/$', views.post_edit, name='post_edit'),
@@ -12,4 +13,3 @@ urlpatterns = [
url(r'^post/(?P<pk>\d+)/remove/$', views.post_remove, name='post_remove'),
]

""" url(r'^search/', views.blog_search_list_view, name='blog_search_list_view'), """

+ 1
- 2
application/views.py View File

@@ -112,7 +112,6 @@ def post_remove(request, pk):
def student_page(request):
return render(request, 'student_page.html', {})

""" Search for querys
def blog_search_list_view(post_list, self):
result = super(post_list, self).get_queryset()
query = self.request.GET.get('q')
@@ -124,4 +123,4 @@ def blog_search_list_view(post_list, self):
reduce(operator.and_,
(Q(content__icontains=q) for q in query_list))
)
return result """
return result

Loading…
Cancel
Save