Django Custom Template Tages: Inclusion Tags
Posted
by Harry
on Stack Overflow
See other posts from Stack Overflow
or by Harry
Published on 2010-03-03T09:47:56Z
Indexed on
2010/05/06
5:48 UTC
Read the original article
Hit count: 393
Hello world!
Im trieng to build my own template tags Im have no idea why I get the errors I get, im following the django doc's.
this is my file structure of my app:
pollquiz/
__init__.py
show_pollquiz.html
showpollquiz.py
This is showpollquiz.py:
from django import template
from pollquiz.models import PollQuiz, Choice
register = template.Library()
@register.inclusion_tag('show_pollquiz.html')
def show_poll():
poll = Choice.objects.all()
return { 'poll' : poll }
html file:
<ul>
{% for poll in poll
<li>{{ poll.pollquiz }}</li>
{% endfor
</ul>
in my base.html file im am including like this
{% load showpollquiz %}
and
{% poll_quiz %}
Bu then I get the the error:
Exception Value: Caught an exception while rendering: show_pollquiz.html
I have no idea why this happens. Any ideas? Please keep in mind Im still new to Django
© Stack Overflow or respective owner