I propose adding a new parameter to the internal API
django.utils.html.urlize and the public template filters `urlize` and
`urlizetrunc`.
--
Ticket URL: <https://code.djangoproject.com/ticket/33692>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by Carlton Gibson):
Stack Overflow has a suggestion here:
{{{
# <app name>/templatetags/url_target_blank.py
from django import template
register = template.Library()
def url_target_blank(text):
return text.replace('<a ', '<a target="_blank" ')
url_target_blank = register.filter(url_target_blank, is_safe = True)
}}}
Example of usage:
{{{
{% load url_target_blank %}
...
{{ post_body|urlize|url_target_blank }}
}}}
https://stackoverflow.com/questions/2295725/extending-urlize-in-django
I don't know if that's good enough finally, or whether it's worth adding
the API here, but it would serve as a workaround.
--
Ticket URL: <https://code.djangoproject.com/ticket/33692#comment:1>
Comment (by Timothy Schilling):
Ah, that will do for me. I probably should have come up with that myself.
I'd be happy to write up the PR for this if there's consensus on adding
it. Otherwise this can be closed as the workaround is sufficient.
--
Ticket URL: <https://code.djangoproject.com/ticket/33692#comment:2>
* status: new => closed
* resolution: => wontfix
Comment:
Thanks Tim! In that case, let's say `wontfix` as no-code beats code 9
times out of 10 🙂
--
Ticket URL: <https://code.djangoproject.com/ticket/33692#comment:3>