fix templatemixin

This commit is contained in:
bkfox 2017-08-17 16:33:11 +02:00
parent 41af970e77
commit 724466618b

View File

@ -11,7 +11,6 @@ class TemplateMixinMeta(models.base.ModelBase):
one, and throw error if there is an error in the template. one, and throw error if there is an error in the template.
""" """
def __new__(cls, name, bases, attrs): def __new__(cls, name, bases, attrs):
from django.template.loader import get_template
from django.template import TemplateDoesNotExist from django.template import TemplateDoesNotExist
cl = super().__new__(cls, name, bases, attrs) cl = super().__new__(cls, name, bases, attrs)
@ -26,9 +25,11 @@ class TemplateMixinMeta(models.base.ModelBase):
) )
if name != 'SectionItem': if name != 'SectionItem':
try: try:
from django.template.loader import get_template
get_template(cl.template) get_template(cl.template)
except TemplateDoesNotExist: except (TemplateDoesNotExist, InvalidTemplateLirary) as e:
cl.template = 'aircox_cms/sections/section_item.html' cl.template = 'aircox_cms/sections/section_item.html'
print('TemplateMixin error:', e)
return cl return cl