0
format_html_join(
        '<br>', '<br><a href="{}">{}</a>', (
            (reverse("admin:research_webproductpage_change", args=[wpp.id]), wpp.title[:30]) for wpp in webproductpages
            )
        )

Above I am trying to add many to many links to my django admin list display which I did succesfully. But <br> or "\n" not working as seperators, although <br> is working in the second parameter. If I put <br> in the first parameter it appears in double quote not as an html. Or If I put "\n" it does not appear at all.
I want to put links row by row because o it looks better then. What is wrong with my code?

2 Answers 2

1

You can mark your separator safe !

from django.utils.safestring import mark_safe

format_html_join(
    mark_safe('<br>'),
    '<a href="{}">{}</a>',
    ...
)
Sign up to request clarification or add additional context in comments.

Comments

0

Can you try this

format_html_join(
        '\n', "<a href='{}'>{}</a>", (
            (reverse("admin:research_webproductpage_change", args=[wpp.id]), wpp.title[:30]) for wpp in webproductpages
            )
        )

1 Comment

<td class="field-link_to_listings"><a href="/admin/research/webproductpage/5323/change/">Anchor Hocking 93013A Barbary </a> <a href="/admin/research/webproductpage/41891/change/">Anchor Hocking 93013A 5 oz Bar</a></td> tried this already but it does not create a new line

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.