Tutorial :Custom Markup in Django


Can anyone give me an idea or perhaps some references on how to create custom markups for django using textile or Markdown(or am I thinking wrong here)?

For example: I'd like to convert the following markups(the outer bracket mean they are grouped as one tag:
* Contact #1
* Contact #2
* Contact #3
[Friend Requests]
* Jose

to have them converted to:

<div class="tabs">        <ul>           <li class="tab">Contacts</li>           <li>Contact #1</li>          (etc.. etc..)      </ul>  </div>    

or is regex more recommended for my needs?


The built in markup app uses a filter template tag to render textile, markdown and restructuredtext. If that is not what your looking for, another option is to use a 'markup' field. e.g.,

class TownHallUpdate(models.Model):      content = models.TextField()      content_html = models.TextField(editable=False)        def save(self, **kwargs):          self.content_html = textile.textile(sanitize_html(self.content))      super(TownHallUpdate, self).save(**kwargs)  

Example from James Tauber's (and Brian Rosner's) django patterns talk.


Django comes with a built-in contrib app that provides filters to display data using several different markup languages, including textile and markdown.

See the relevant docs for more info.


A quick google search resulted with this


Well it seems the best way is still use a regex and create my own filter.

here are some links that helped me out:

hope this helps someone who had the same problem as me!

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »