This field is used for storing template-strings in database.

You can't just store django.template.Template() in the field, because we can't
convert it back to the string. Please store a string with template instead, it
will be converted to the Template() automagically.


1. Add templatefield/ directory to your python import path (for example, copy it
into the directory with your other apps).

2. Define a form with a template, like:

from templatefield.fields import TemplateField

class Widget(models.Model):
    template = TemplateField()

3. In the admin, in the form, in the shell or in your app code you can save
any template string to this field:

>>> from my_app.models import Widget
>>> w = Widget(template="Hello, {{ username }}!")
>>> w.template
<templatefield.fields.StoredTemplate object at 0x2bc0f50>


4. Render a template as your usual Template:
>>> from django.template import Context
>>> w.template.render(Context({'username': 'Bob Marley'}))
u'Hello, Bob Marley!'