I am trying to display a bit of html in a message that displays through the new Django message structure. In particular, I do this using the ModelAdmin.message_user method, which is just a thin shell of messages ():
def message_user(self, request, message): """ Send a message to the user. The default implementation posts a message using the django.contrib.messages backend. """ messages.info(request, message)
Everything I've tried so far seems to display escaped HTML.
self.message_user(request, "<a href=\"http://www.google.com\">Here google!</a>")
Doesn't work and doesn't work:
from django.utils.safestring import mark_safe ... self.message_user(request, mark_safe("<a href=\"http://www.google.com\">Here google!</a>"))
Displaying the template code in the admin template base.html is pretty simple:
{% if messages %} <ul class="messagelist">{% for message in messages %}<li>{{ message }}</li>{% endfor %}</ul> {% endif %}
Therefore, I am not entirely sure what I am doing wrong.
Thoughts or guidance were greatly appreciated, thanks!
django
jsdalton Jan 12 '10 at 23:30 2010-01-12 23:30
source share