Several views loaded into the template

Sen guys, in PHP, when I want to load a differnet page (rendering, when outputting all variables), I would use

include 'mypage.php' 

This will load the page and display the results.

How do I do something like this in Django? My problem is that I have a "quick list" that lists many popular items. I want this list to appear on every page, even if I do not call the object.

any ideas?

EDIT: view is called shop.app.popular_items

+4
source share
4 answers

You can use inclusion tags .

+3
source

Edit:

After Daniel’s answer and, as you said, you want to have it on every page,
getting a response to the guru is probably the best solution.


This does not apply to the view (unless you want to display it as a separate page).

This should go into the custom template tag .

+2
source

To answer your question, to become a guru, when to use context processors and when to use inclusion tags, remember that context processors are launched on every rendering of the template. Therefore, they should only be used when you know that you always need a value.

+1
source

Source: https://habr.com/ru/post/1299958/


All Articles