Убрал дублирование заголовков + теперь только статьи отображаются

remotes/origin/upgrade-requirements
Alexander Kondratyev 9 years ago
parent cf9b7b2ec2
commit b06fba71f4
  1. 7
      zsite/templates/aldryn_people/includes/people_item.html
  2. 12
      zsite/templatetags/query.py

@ -1,4 +1,4 @@
{% load menu_tags aldryn_people_tags cms_tags i18n thumbnail %} {% load menu_tags aldryn_people_tags cms_tags i18n thumbnail query %}
{% show_breadcrumb 2 %} {% show_breadcrumb 2 %}
@ -28,8 +28,9 @@
{% spaceless %} {% spaceless %}
<h2>Статьи</h2> <h2>Статьи</h2>
<ul class="articles list-unstyled"> <ul class="articles list-unstyled">
{% for article in person.blog_post_author.all %} {% query person.blog_post_author categories__id=4 as articles %}
{{ article }}
{% for article in articles %}
<li><a href="{{ article.get_absolute_url }}">{{ article.title }}</a> <li><a href="{{ article.get_absolute_url }}">{{ article.title }}</a>
&nbsp;<small class="date">{{ article.date_published|date:"DATE_FORMAT" }}</small></li> &nbsp;<small class="date">{{ article.date_published|date:"DATE_FORMAT" }}</small></li>
{% endfor %} {% endfor %}

@ -0,0 +1,12 @@
from django import template
register = template.Library()
@register.assignment_tag
def query(qs, **kwargs):
""" template tag which allows queryset filtering. Usage:
{% query books author=author as mybooks %}
{% for book in mybooks %}
...
{% endfor %}
"""
return qs.filter(**kwargs)
Loading…
Cancel
Save