2👍
✅
In your template tag you got the parser. You can use it to get the source file and the current character in the template like this:
@register.tag
def mytemplatetag(parser, token):
template_loader, position = parser.command_stack[0][-1]
print template_loader.loadname, position
Source:stackexchange.com