Найти - Пользователи
Полная версия: Как можно передать request в tamplatetags?
Начало » Django » Как можно передать request в tamplatetags?
1
victor_91


Ребят помогите. Как можно передать request в tamplatetags? Мне нужно сделать такой tamplatetags. Очень нужен ваш совет.

from django import template
from blog.models import Follow, Post
register = template.Library()

@register.inclusion_tag('feeds.html')
def feed_tag():
user = request.user
foll_ids = Follow.objects.values_list('followee_id', flat=True).filter(follower=user)
post_foll = Post.objects.filter(blog__author_id__in=set(foll_ids))
return {'post_foll': post_foll}

FishHook
нагуглил секунды за 4
http://stackoverflow.com/questions/2160261/access-request-in-django-custom-template-tags
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB