I'm creating custom template tags for my django site. I've followed the django documentation for this and have created a templatetags
directory in my main application.
/project/apps/core/templatetags
-/__init__.py
-/core_extras.py
Since I am not sure if this is causing the problem, I should note I have this in my settings.py
sys.path.insert(0, join(PROJECT_ROOT, "apps"))
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_evolution',
'apps.core',
)
core_extras.py
from django import template
import settings
register = template.Library()
class SiteNameNode(template.Node):
def __init__(self):
def render(self, context):
site_name = getarrr(settings, "SITE_NAME", false)
if not site_name:
return "<!-- SITE_NAME not setting in Settings -->"
if settings.DEBUG:
return 'Debug || ' + site_name
return site_name
@register.tag(name="site_name")
def find_site_name(parser, token):
return SiteNameNode()
main.html
{% load core_extras %}
Error
In template /cygdrive/d/Users/Kin/BitNami DjangoStack projects/flipfinder/templates/main.html, error at line 1
'core_extras' is not a valid tag library: Template library core_extras not found, tried django.templatetags.core_extras,django.contrib.admin.templatetags.core_extras
Has anyone else run into a problem like this? Am I missing something obvious. I've went through and double checked everything, but I can't seem to find anyone with a similar problem.
from apps.core.templatetags import core_extras
- if there's an error in the file, that'll tell you the real one. Like sdolan said in his answer, django's template system is horrid at reporting the real errors – Japeth