{{{
#!python
@register.inclusion_tag('template.html', takes_context=True)
@my_decorator
def my_tag(context, arg):
# Code
}}}
However, I found that if `name='my_tag'` is added to the `inclusion_tag()`
call, then it worked. This wasn't easy to figure out and doesn't seem to
be documented. It just silently failed with no easy way to troubleshoot.
It seems like the tag should work without needing to add the `name`
argument.
--
Ticket URL: <https://code.djangoproject.com/ticket/24586>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* cc: chris.jerdonek@… (added)
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/24586#comment:1>
Comment (by prestontimmons):
I can see how this would be confusing, but I'm not sure it's a Django
problem.
The key to fixing your example is making sure your decorator uses
`functools.wraps`. This will carry through the `__name__` attribute from
the original `my_tag` function. Otherwise, that piece of information is
lost and the tag will be registered with whatever the name is of the inner
function in your decorator.
--
Ticket URL: <https://code.djangoproject.com/ticket/24586#comment:2>
* status: new => closed
* resolution: => invalid
--
Ticket URL: <https://code.djangoproject.com/ticket/24586#comment:3>
Comment (by cjerdonek):
Thanks, @prestontimmons. That makes sense.
--
Ticket URL: <https://code.djangoproject.com/ticket/24586#comment:4>