- How to make a reusable template in Django?
- from django import template
- register = template.Library()
- register.inclusion_tag('results.html')
- def show_results(poll):
- choices = poll.choice_set.all()
- return {'choices': choices}
- <ul>
- {% for choice in choices %}
- <li> {{ choice }} </li>
- {% endfor %}
- </ul>
- {% load poll_extras %}
- {% show_results poll %}