I think you're looking for this tutorial Chapter 4 of the Django book: The Django Template System.
See block tags and template inheritance.
Brian R. Bondy
2009-08-07 21:37:00
I think you're looking for this tutorial Chapter 4 of the Django book: The Django Template System.
See block tags and template inheritance.
In your python code:
context['books'] = blah blah # Make a list of books somehow.
return render_to_response('popular_books.html', context)
In popular_books.html:
<p>Look, books:</p>
{% for book in books %}
{% include "book.html" %}
{% endfor %}
Finally, in book.html:
<p>I am a book, my name is {{book.name}}</p>
There are more interesting ways to modularize, such as creating a custom tag, so that you could, for example:
<p>Look, books:</p>
{% for b in books %}
{% book b %}
{% endfor %}