One of the big downfalls of storing bits of templates in your database is that you’re limited to HTML/CSS/JavaScript. Individuals editing flatpages can’t use template filters or other bits of Django’s awesome templating language.
Usually this doesn’t make much sense, but for one CMS use-case (linking to other pages by identifier and not hard-coding their URL), it could make a big different.
In that vein, Kyle Fox posted a comment on my post about django-chunks and mentioned that he had developed a template tag that allows individuals to insert Django templating language into Flatpages (and chunks!)
This tag will let you write django template code into, for example, a Flatpage’s content and render it with the current context. So if you had a template tag called “get_latest_news” and wanted to add latest news to a flatpage, just enter this in the flatpage’s content:
{% get_latest_news 5 as news %}
{% for article in news %}
<li>{{ article.title }}</li>
{% endfor %}
This ability has proven extremely useful to us. Please note this is just a “summary” snippet to illustrate the concept. Use in a production environment should include more robust error checking.
Øyvind Saltvik also wrote in to tell me about two other projects that allow you to store more of your projects in the database:
Thanks everyone!