1. Shu Zong Chen
  2. django-snippet


Clone wiki

django-snippet / Home


Django-snippet is a simple drop in django application to provide snippet blocks in your templates. Snippets are blocks or lines of text that can be modified using the django backend.


  • pip install django-snippet
  • add 'snippet' to your INSTALLED_APPS
  • python manage.py syncdb

Simply Put

Stick in {% snippet "snippet_name" %} in your template, and when that template gets loaded, the snippet is automatically registered in the backend.

Basic Usage

{% snippet "snippet_name" %}

This is the simplest type of snippet.

Providing Default Value

{% snippet "snippet_name" "my default value" %}

You can provide a default value for the snippet. This is the value that will be saved into the database if the snippet hasn't been registered (or has been deleted)

Longer Default Values

{% snippetblock "snippet_name"%}
{% endsnippetblock %}

If you have a longer block of text (say, a whole chunk of html) then you can use the snippetblock template tag instead.