django-dbtemplates/template/models.py
leidel f4e0431359 initial commit
git-svn-id: https://django-dbtemplates.googlecode.com/svn/trunk@2 cfb8ba98-e953-0410-9cff-959ffddf5974

committer: leidel <leidel@cfb8ba98-e953-0410-9cff-959ffddf5974>

--HG--
extra : convert_revision : 0394ad2382d7c7fc9d0ea40cf43777f7621d2ec3
2007-02-23 19:03:20 +00:00

28 lines
No EOL
1.1 KiB
Python

from django.db import models
from django.core import validators
from django.contrib.sites.models import Site
from django.utils.translation import gettext_lazy as _
class Template(models.Model):
"""
Defines a template model for use with the database template loader.
The field ``name`` is the equivalent to the filename of a static template.
"""
name = models.CharField(_('name'), unique=True, maxlength=100, help_text=_("Example: 'flatpages/default.html'"))
content = models.TextField(_('content'))
sites = models.ManyToManyField(Site)
creation_date = models.DateTimeField(_('creation date'), auto_now_add=True)
last_changed = models.DateTimeField(_('last changed'), auto_now=True)
class Meta:
db_table = 'django_template'
verbose_name = _('template')
verbose_name_plural = _('templates')
ordering = ('name',)
class Admin:
fields = ((None, {'fields': ('name', 'content', 'sites')}),)
list_display = ('name', 'creation_date', 'last_changed')
list_filter = ('sites',)
search_fields = ('name','content')
def __str__(self):
return self.name