Search code examples
djangodjango-admin

Show Button in Admin ListView - Upgrade to Django 4


I have upgraded to django 4.2.2. from 1.X. In my listview I have buttons for every element, the button contains a link. Everything worked well but after upgrading the quotes are rendered as '&quot' in html instead of '"'.

def clone_button(self,obj):
    button = "<button type=\"button\" onclick=\"location.href='/admin/clone/%s/%s'\";>Clone</button>" % (obj.id,"keep_date")
    return button
clone_button.allow_tags=True 

What do I have to do differently now?


Solution

  • Mark the html string as safe for output. Or use the html_output shortcut.