Задать вопрос

Тел: +7 965 3737 888





Template filter for internal links in TextFields

<p>Allows for in internal link markup to be saved inside markdown-formatted Textfield entries.</p>
<p>Using the filter, the link is only looked up at display time, so if your view's URL has changed, that should automatically update with the reverse() lookup.</p>
<p>You could tweak the regex pattern to match whatever link markup you prefer. I also use Markdown to process my description fields, so I make the link return a markdown-formatted link instead of HTML, but you could tweak that too. If you use Markdown, you'd want to put this filter first.</p>
<p>So to display a description TextField with internal links, in the template would be something like this:</p>
<p>{{ entity.description|internal_links|markdown }}</p>
<p>(See the <a href="https://docs.djangoproject.com/en/1.6/howto/custom-template-tags/#writing-custom-template-filters">Django docs on writing your own custom filters</a> for more details on writing and registering filters.)</p>
<p>Written for <a href="http://opticalpodcast.com">my own website</a>, and a basic version was shared as the <a href="http://stackoverflow.com/a/26812762/429070">answer to this Stack Overflow question</a>.</p>

Вопрос полезен? Да0/Нет0