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

{% endif %} {% endif %}
<h1>{{ post.title }}</h1> <h1>{{ post.title }}</h1>
<p>{{ post.text|linebreaksbr }}</p> <p>{{ post.text|linebreaksbr }}</p>
<p>{{ post.tag }}</p>

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

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

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


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

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

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

+ 1
- 1
application/urls.py View File

urlpatterns = [ urlpatterns = [
url(r'^$', views.post_list, name='post_list'), url(r'^$', views.post_list, name='post_list'),
url(r'^student/', views.student_page, name='student_page'), 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/(?P<pk>\d+)/$', views.post_detail, name='post_detail'),
url(r'^post/new/$', views.post_new, name='post_new'), url(r'^post/new/$', views.post_new, name='post_new'),
url(r'^post/(?P<pk>\d+)/edit/$', views.post_edit, name='post_edit'), url(r'^post/(?P<pk>\d+)/edit/$', views.post_edit, name='post_edit'),
url(r'^post/(?P<pk>\d+)/remove/$', views.post_remove, name='post_remove'), 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

def student_page(request): def student_page(request):
return render(request, 'student_page.html', {}) return render(request, 'student_page.html', {})


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

Loading…
Cancel
Save