On 8/16/06, Seth Buntin <[EMAIL PROTECTED]> wrote: > I have created a custom template tag that gets specific information > from the database: > > linkroll.py: > from django.core import template > from seth_blog.blog.models import Linkroll > register = template.Library() > > def linkroll(): > links = Linkroll.objects.all()[:5] > return {'links': links} > > # Here, register is a django.template.Library instance, as before > register.inclusion_tag('linkroll.html')(linkroll) > > I assume that is right. It is located under app/templatetags/. The > templatetags folder also contains an __init__.py file. I have the > linkroll.html file in my applications template directory. I also put > {% load linkroll %} in my base.html template. When I go to the site I > get this error: > > TemplateSyntaxError at / > 'linkroll' is not a valid tag library: Could not load template library > from django.templatetags.linkroll, cannot import name template > Request Method: GET > Request URL: http://localhost:8000/ > Exception Type: TemplateSyntaxError > Exception Value: 'linkroll' is not a valid tag library: Could not load > template library from django.templatetags.linkroll, cannot import name > template > Exception Location: > /usr/lib/python2.4/site-packages/django/template/defaulttags.py in > load, line 692 > > What am I not doing right?
The key is the exception message: "cannot import name template". Your templatetag library contains the line "from django.core import template", but as of Django 0.95, the import statement should be "from django import template". Assuming you're on 0.95, that's the problem. Adrian -- Adrian Holovaty holovaty.com | djangoproject.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---