T
T
Tash1moto2016-02-24 11:52:34
Django
Tash1moto, 2016-02-24 11:52:34

How to properly break a template in Django?

Hello.
I have base template base and many other pages that extend base.
In the view, I do my own logic for each page, I render, everything is fine,
but in the base template there is a sidebar visible on all pages, which counts the number of all products, but
I can only transfer logic for one page.
How can I make the logic for the base template or still pass data for the sidebar in each template?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Peter, 2016-02-24
@petermzg

You can define your own TEMPLATE_CONTEXT_PROCESSORS and logic in it

D
Dmitry Voronkov, 2016-02-24
@DmitryVoronkov

Why such difficulties. Make your templatetag
docs

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question