Найти - Пользователи
Полная версия: получить переменную request
Начало » Django » получить переменную request
1
yiooxir
Использую inclusion_tag, а в нем надо использовать переменную request. Но она там не определена. Как мне ее получить, из шаблона что-ли передавать?

@register.inclusion_tag('HD_basket.html')
def HD_basket_view(request):
return {'HD_basket_view':V_Basket(request).GetDataCount(),}
Antonio051
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)
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