Форум сайта python.su
Использую inclusion_tag, а в нем надо использовать переменную request. Но она там не определена. Как мне ее получить, из шаблона что-ли передавать?
@register.inclusion_tag('HD_basket.html')
def HD_basket_view(request):
return {'HD_basket_view':V_Basket(request).GetDataCount(),}
Офлайн
https://docs.djangoproject.com/en/1.4/howto/custom-template-tags/#inclusion-tags
# The first argument *must* be called "context" here. def jump_link(context): return { 'link': context['home_link'], 'title': context['home_title'], } # Register the custom tag as an inclusion tag with takes_context=True. register.inclusion_tag('link.html', takes_context=True)(jump_link)
Офлайн