For the longest time, I've been using markdown in the Django template engine. This is the dumb way of implementing markdown in Django. It's slow to render and it puts too much programming into the template system, which is against Django philosophy.
The smart way to add markdown functionality is by extending the save method of your models. On this little blog for instance, I have an Entry model. This is what the save method looks like.
def save(self): self.body = markdown.markdown(self.body_markdown, safe_mode='escape') super(Entry, self).save()
I have two fields that hold the different bodies. The body_markdown is the body of the Entry with markdown markup and the body field is the html version. No extra programming is required. Whenever an Entry is saved, a new html body is created using markdown. Then, the models.Model save method is called and the model is written to the database.
Now, instead of markdown parsing every page load as it would have through templates, it does it once per save. The only downside of this approach is you are using up more than twice as much space for each Entry. Disk space is cheaper than cycles, memory, and your visitors' patience though.
