My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Links

Snippetology lets you pull text snippets from the database and inject them into your Django templates (or directly into your view code). If text sounds boring, it shouldn't - the snippets can be any HTML content including flash or image tags, regular markup, CSS, Javascript, etc..

This is a very simple but commonly requested CMS feature, where content can be changed dynamically by a trusted non-technical administrator. Snippet text is editable from the regular Django admin panel and the output text appears anywhere you place the matching snippet tag in your template.

A randomizing filter is also included that will let you randomly emit lines from a particular snippet. This can be handy for page taglines or rotating banner ads, etc.

Install

  1. Get tarball or the latest via svn http://code.google.com/p/django-snippetology/source/checkout
  2. Either run setup.py install or put the inner snippetology folder in your Django project folder or on your PYTHONPATH.
  3. Add 'snippetology' to INSTALLED_APPS in settings.py
  4. manage.py syncdb

Using Snippets

  1. Go into your Django admin and create some snippets in the Snippetology section. Careful - the name you give your snippet will be the name you use in your template.
  2. Add the command {% load snippets %} toward the top of your template file.
  3. To use a snippet add a snippet tag to your template: {% snippet "daily message" %} where "daily message" is an example snippet name.

Randomizing Snippets

The random_line tag will randomly select one line out of a snippet full of lines of text. Blank lines are ignored. To use the randomizing feature:

  1. Create a snippet with multiple lines of text.
  2. Use the following tag to randomly choose and display a line:
{% filter random_line %}{% snippet "rotating_banner_list" %}{% endfilter %}

Important Notes

Snippetology is appropriate to workgroup sites, intranets, and low volume public websites. Running unmodified on higher volume sites probably isn't a great idea because of the database hits you'd rack up. Caching support and other performance features are in the works but are not a priority at this time. Suffice it to say that if you're not running a high volume website you likely won't experience performance problems with Snippetology.

Similar Apps

Apparently there is a strong desire for named snippets. There are several projects which provide similar functionality that you might find more useful:

  • django-flatcontent
  • django-chunks
  • django-flatblocks
  • django-generic-flatblocks
Powered by Google Project Hosting