mirror of
https://github.com/jazzband/django-dbtemplates.git
synced 2026-03-16 22:20:28 +00:00
Split out an AbstractTemplate model for easier reuse (#150)
This commit is contained in:
parent
303bd0cabe
commit
05f1ee1193
1 changed files with 9 additions and 2 deletions
|
|
@ -13,7 +13,7 @@ from django.template import TemplateDoesNotExist
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
class Template(models.Model):
|
class AbstractTemplateMixin(models.Model):
|
||||||
"""
|
"""
|
||||||
Defines a template model for use with the database template loader.
|
Defines a template model for use with the database template loader.
|
||||||
The field ``name`` is the equivalent to the filename of a static template.
|
The field ``name`` is the equivalent to the filename of a static template.
|
||||||
|
|
@ -32,7 +32,7 @@ class Template(models.Model):
|
||||||
on_site = CurrentSiteManager('sites')
|
on_site = CurrentSiteManager('sites')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'django_template'
|
abstract = True
|
||||||
verbose_name = _('template')
|
verbose_name = _('template')
|
||||||
verbose_name_plural = _('templates')
|
verbose_name_plural = _('templates')
|
||||||
ordering = ('name',)
|
ordering = ('name',)
|
||||||
|
|
@ -62,6 +62,13 @@ class Template(models.Model):
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class Template(AbstractTemplateMixin, models.Model):
|
||||||
|
class Meta(AbstractTemplateMixin.Meta):
|
||||||
|
db_table = 'django_template'
|
||||||
|
verbose_name = _('template')
|
||||||
|
verbose_name_plural = _('templates')
|
||||||
|
|
||||||
|
|
||||||
def add_default_site(instance, **kwargs):
|
def add_default_site(instance, **kwargs):
|
||||||
"""
|
"""
|
||||||
Called via Django's signals to cache the templates, if the template
|
Called via Django's signals to cache the templates, if the template
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue