Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 25th, 2012  |  syntax: None  |  size: 0.36 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to make a reusable template in Django?
  2. from django import template
  3. register = template.Library()
  4.  
  5. register.inclusion_tag('results.html')
  6. def show_results(poll):
  7.     choices = poll.choice_set.all()
  8.     return {'choices': choices}
  9.        
  10. <ul>
  11. {% for choice in choices %}
  12.     <li> {{ choice }} </li>
  13. {% endfor %}
  14. </ul>
  15.        
  16. {% load poll_extras %}
  17. {% show_results poll %}