[Answered ]-Can i use templatetags inside inclusion tags?

2👍

The included template, vote_buttons.html requires a {{ user }} context variable. vote_button_for does not return a dict with a ‘user’ item. Assuming {{ user }} should be the request user, you could use something like this:

@register.inclusion_tag('vote_buttons.html',takes_context=True)
def vote_buttons_for(context, object, *args, **kwargs):
    return {
        "user": context['user'],
        "object": object,
        "vote_model": "%s.%sVote" % (
            object._meta.app_label, object._meta.object_name)
    }
👤jpic

Leave a comment