Take the 2-minute tour ×

I'm working on my first Django project and have my templates setup with a base that all the others extend. In that base I want to have some user-specific navigation which means loading some values from the database to build the contents of a drop down menu. However I don't want to have to do this inside each view. Coming from Symfony2/Twig I would normally do this using a sub-request where I tell the template to render a view and that will use it's own template. Using syntax like:

{% render 'Bundle:Controller:action' with {} %}

How would I accomplish this same thing with Django? I've read over the docs a couple of times but can't find any way to do this.

share|improve this question

2 Answers 2

You have two approaches:

(better) - add the code to base.html (the one you're always extending) and only override it when you need to.


(worse) - in every template use {% include %} to include your menus.html template.

Update: re-reading your question: you could modify the request in context-processor so your base.html would then have this information.

share|improve this answer

Custom template tags are what you want.

share|improve this answer

Your Answer


