title: django render an object as html in a template
body: <p>I am trying to render an object in a template like what we can do with forms <code>{{ form }}</code> but the output is turned into text and not html code. How to really include html code?</p>
  
  <pre><code>my_object = MyObject()
  {{ my_object }}
  </code></pre>
  
  <p>The class:</p>
  
  <pre><code>from django.template import Context, Template
  from django.utils.safestring import mark_safe
  
  class MyObject(object):
  
      def __str__(self):
          return self.render()
  
      def render(self):
          t = Template('&lt;p&gt;This is your &lt;span&gt;{{ message }}&lt;/span&gt;.&lt;/p&gt;')
          c = Context({'message': 'Your message'})
          html = t.render(c)
          return mark_safe(html)
  </code></pre>