improve template not found debugging

This commit is contained in:
Sanj 2011-09-10 08:15:52 +05:30
parent 8b132b029e
commit a691694a62

View File

@ -7,6 +7,7 @@ from django.core.paginator import Paginator, InvalidPage, EmptyPage
from django.template.loader import render_to_string from django.template.loader import render_to_string
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from insidepages.models import ModuleTab, ModelExtra from insidepages.models import ModuleTab, ModelExtra
from os.path import exists
def splitSearch(string): def splitSearch(string):
ret = [] ret = []
@ -80,10 +81,14 @@ class ItfModel(models.Model):
return self.get(self._get_fields().keys()) return self.get(self._get_fields().keys())
def insidepage_dict(self): def insidepage_dict(self):
if not exists(self.get_template_path()):
return {
'html': "Template for this model not found."
}
try: try:
html = render_to_string(self.get_template_path(), self.info_dict()) html = render_to_string(self.get_template_path(), self.info_dict())
except: except:
html = "Template for this model not found." html = "Template render error."
return { return {
'url': self.get_absolute_url(), 'url': self.get_absolute_url(),
'title': self.get_title(), 'title': self.get_title(),