Torsten Bronger
unread,May 8, 2018, 4:45:14 PM5/8/18Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
Hallöchen!
Up to Django 1.11, I had the following pattern frequently in my
code:
@register.filter
@mark_safe
def myfilter(value):
...
Smilarly for tags. This has worked for years, however, with Django
2.0, this leads to the TemplateError saying that "myfilter requires
0 arguments, 1 provided". For tags, it results in an IndexError
because the "params" list when processing the tag is empty.
If I make @mark_safe the outmost (i.e. first) decorator, no
exception occurs – but the output is escaped HTML instead of
passed-through HTML.
The safe and obvious workaround is to use mark_safe() as a function
instead of @mark_safe. Would be a pity, though.
Is this a bug or am I doing something wrong?
Tschö,
Torsten.
--
Torsten Bronger