I try to make my own assignment template tag in Django 1.6 (edit: I also tried it with 1.5.5 w/o success) but I can't get it to do anything.
In templatetags/getattribute.py
I have:
from django import template
import logging
register = template.Library()
logger = logging.getLogger('wwwcid.website.debug_console')
#@register.assignment_tag
def mytag(context, context_variable):
raise template.TemplateSyntaxError("buuuuuuuuuuuuuuus")
logger.debug("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
print "teeeeeeeeeeeeeeeeeeeest"
return 'tpppppppppppppppppppppeee'
register.assignment_tag(mytag, takes_context=True)
In my template profile.html
I have:
{% extends "website/base.html" %}
{% load getattribute %}
{% mytag "user.email" as vari %}
{{ vari }}
{% block content %}
<p> Rest of the page. </p>
{% endblock content %}
But this tag does not work. No error is raised (even if I raise it myself), no logging output, no print, no return, nothing.
Even if I register the tag w/o the takes_context=True, say just @register.assignment_tag
it does not work. What am I doing wrong here? Thanks for your help!