Detail: variable from templatetag (python)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
/** Templatetag **/
@register.simple_tag
def ret_last_comments(limit):
    from blog.models import Comment
    last_comm = Comment.objects.all().filter(status=1).order_by('-creation_date')[:limit]
    print last_comm
    return {'last_comm': last_comm }


/** Template **/
    <ul class="lc-ico">
    {% ret_last_comments 8 %}
    {% for comment in last_comm %}
			<li style="display: inline;background: none; margin: 0; padding: 0;">
			    <a href="" class="a-ico">*
			        <!--{% gravatar comment.author_email 44 "g" "not_gravatar.png" %}-->
			    </a>
			</li>
    {% empty %}
        <li>{{ _('No comments yet') }}</li>
    {% endfor %}
    </ul>

[raw] - Pasted by: rsk on python on Aug. 24, 2011