views:

49

answers:

1

Hey Guys!

I am currently facing a serious problem. I use the standard django admin interface incl. change list to display one of my models. The model has got a field, which includes a link (e.g. in database: link).

What I want now is that this string is rendered unescaped and displayed as link. I already tried the following in "change_list_results.html":

{% for result in results %}
<tr id="{{ result.1|adminfilter }}" class="{% cycle 'row1' 'row2' %}">
    {% for item in result %}
        {{ item|safe }}
    {% endfor %}</tr>
{% endfor %}

I used "|safe" on the actual item that is output. Furthermore i tried "{% autoescape off %}". Same result, the String got escaped.

Do you see any other way to get the String displayed unescaped?

+1  A: 

You want to set allow_tags=True on your method. It's a bit hidden, but it is described in the documentation - about a screen or so down from where this link takes you.

Daniel Roseman
Daniel, thanks for the hint. I had to define a method in the model which returns the link and mark this method.allow_tags = True.
Michael S