Insert html django contrib messages
Submitted by jeff on Mon, 01/23/2012 - 22:56.
I wanted to use raw HTML in certain invocations of Django’s Messages architecture such as in messages.success.
When sending your message:
messages.success(request, mark_safe("""Thanks for your purchase. Your <a href="%s">Account > Payment</a>""" % urlresolvers.reverse(‘account_payment_detail’, kwargs = {‘id’:payment.id}) ), extra_tags=‘html’)
Modify your Django snippet to skip the web-safe encoding:
{% if ‘html’ in message.tags %}
{{ message|safe }}
{% else %}
{{ message }}
{% endif %}Recent blog posts
- Amazon S3 Website CNAME
- Button labels for checkout
- Insert html django contrib messages
- Twitter Bootstrap not working with LESS.js
- Javascript libs that offer basic subset of jquery features
- Building the donor-matic
- Playing with free Google Map alternatives.
- Some flows are not as complicated as they appear
- Form design crib sheet
- Script to get IE9 Windows Virtual PC images into Virtual Box