Добавил вывод тегов на страницу со статьями

remotes/origin/upgrade-requirements
Dmitriy Shesterkin 9 years ago
parent 3d58880607
commit 0b5d5a8f8c
  1. 10
      packages/blog/templates/blog/post_list.html
  2. 5
      packages/blog/views.py
  3. 11
      zsite/static/less/blog.less

@ -11,12 +11,20 @@
<h2>
{% if author %}{% trans "Articles by" %} {{ author.get_full_name }}
{% elif archive_date %}{% trans "Archive" %} &ndash; {% if month %}{{ archive_date|date:'F' }} {% endif %}{{ year }}
{% elif tagged_entries %}{% trans "Tag" %} &ndash; {{ tagged_entries|capfirst }}
{% elif tagged_entries %}{% trans "Tag" %} &ndash; {{ tag|capfirst }}
{% elif category %}{% trans "Category" %} &ndash; {{ category }}{% endif %}
{{ category }}
</h2>
</header>
{% endblock %}
{% if tags %}
<ul class="blog-tags">
{% for tag in tags %}
{{ tag.count }}
<li class="blog-tag"><a class="btn btn-xs btn-default" href="{% url "blog:posts-tagged" tag=tag.slug %}">{{ tag.name }}</a></li>
{% endfor %}
</ul>
{% endif %}
<div class="clearfix"></div>
<div class="blog-list-older">
{% for post in post_list %}

@ -8,7 +8,7 @@ from django.views.generic import ListView, DetailView
from parler.views import ViewUrlMixin, TranslatableSlugMixin
from aldryn_apphooks_config.mixins import AppConfigMixin
from taggit.models import Tag
from .models import Post, BlogCategory, BLOG_CURRENT_POST_IDENTIFIER
from .settings import get_setting
@ -45,6 +45,7 @@ class PostListView(BaseBlogView, ListView):
def get_context_data(self, **kwargs):
context = super(PostListView, self).get_context_data(**kwargs)
context['TRUNCWORDS_COUNT'] = get_setting('POSTS_LIST_TRUNCWORDS_COUNT')
context['tags'] = Tag.objects.all()
return context
@ -106,6 +107,8 @@ class TaggedListView(BaseBlogView, ListView):
kwargs['tagged_entries'] = (self.kwargs.get('tag')
if 'tag' in self.kwargs else None)
context = super(TaggedListView, self).get_context_data(**kwargs)
if kwargs['tagged_entries']:
context['tag'] = Tag.objects.get(slug=kwargs['tagged_entries'])
context['TRUNCWORDS_COUNT'] = get_setting('POSTS_LIST_TRUNCWORDS_COUNT')
return context

@ -105,3 +105,14 @@ article.post-item {
}
/* block tags template blog/post_list.html line 21 */
.blog-tags {
padding-left: 0;
}
.blog-tag {
display: inline-block;
margin: 2px 0;
}

Loading…
Cancel
Save