On 22/10/2013 4:56am, fchow wrote:
My question is about returning HTML markup in a model method vs. a
custom template filter.

Personally, I prefer the custom template filter due to a nicer separation of model/display concerns.

That said, I recently discovered Django's mark_safe()

from django.utils.safestring import mark_safe

def known_good_html(value):
    ...
    return mark_safe(value)

The returned object type is recognised by the template rendering engine as not needing further escaping.

hth

Mike

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5265D97C.3060509%40dewhirst.com.au.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to