2👍
✅
Have a look at the rendered html, for example using your browsers inspect context menu option. I think you could see there that there is a problem with the double quotes you use.
The onclick
-attribute is enclosed by double quotes, but the message passed as argument to confirm()
is also enclosed by double quotes. This results in your browser interpreting the attribute as `onclick=”return confirm(” and ignores the gibberish it cannot understand which is your message.
You can fix that by using single quotes to enclose the message argument to confirm()
, either by escaping them in the syntax you used (\'
), or by using triple quotes like this:
template_code = '''
<a href="/schedule/update_schedule/{{ record.id }}">Update</a> / Cancel / Event /
<a href="/schedule/delete_schedule/{{ record.id }}"
onclick="return confirm('Are you sure you want to delete this?')">Delete</a>'''
Source:stackexchange.com