dotty
dotty

Reputation: 41433

Multiple views loaded into a template

Hay guys, in PHP when i want to load a differnet page (render, with all variables outputting) i would use

include 'mypage.php'

This would load the page up and render the output.

How do i do something like this in Django? My problem is that i have a "quick list" which lists a bunch of popular items. I want this list to appear on every page, even if i don't call the object.

any ideas?

EDIT: The view is called shop.app.popular_items

Upvotes: 4

Views: 2161

Answers (4)

Felix Kling
Felix Kling

Reputation: 816262

Edit:

After Daniel's answer and as you said you want to have it on every page,
becomingGuru's answer is probably the best solution.


This does not belong into the view (if you not want to display this as a standalone page).

This should go into a custom template tag.

Upvotes: 1

Daniel Roseman
Daniel Roseman

Reputation: 599470

To answer your question to becomingGuru on when to use context processors and when to use inclusion tags, remember that context processors are run on every template render. So they should only be used when you know you will always need the value.

Upvotes: 1

Ofri Raviv
Ofri Raviv

Reputation: 24823

You can use Inclusion tags.

Upvotes: 3

lprsd
lprsd

Reputation: 87077

Use template context_processors

Upvotes: 1

Related Questions