views:

49

answers:

2

I have a file called header.html and it is included by base.html. In header.html, I have a list of Categories, which are stored in the database. Now, I want to give that list to header.html. The problem is that no function is known to render the data into this file. So how do I do now. Heartfelt thanks!

A: 

If you want to make variables available in all templates without specifically passing them from a view you can use a Template Context Processor

That will populate your RequestContext, available in the template.

I also suggest you look at Template Inheritence to build the relationships between templates instead of including one within the other.

Andre Miller
+2  A: 

You need a template tag - specifically, an inclusion tag. This will render a template with a custom context, in your case the list of categories.

Daniel Roseman
This solution seems to be satisfactory and easy to understand. Thanks!
Tran Tuan Anh