S
S
Sergey Nizhny Novgorod2016-06-11 01:45:57
Django
Sergey Nizhny Novgorod, 2016-06-11 01:45:57

How to make a pass-through element with dynamic data in Django?

Hello.
Task: to make a cross-cutting banner on the site that can be easily changed (via the admin panel).
How I'm trying to decide:
1) I did: model/url/view/template for a page with a banner. (like a normal page renderer).
2) in the banner template, I specified dynamic data by type

# код внутри шаблона banner.html

<p>{{  banner.img.url }}</p>
<p>{{  banner.link }}</p>

3) Through the inclusion, I inserted the banner page on all pages of the site. As a result, the page displays:
{% include 'faceset/banner.html' %}
<p></p>
<p></p>

those. dynamic data is not picked up.
Can you tell me how this can be done or what is my mistake?
Ps
The documentation says that inclusion blocks are calculated before they are included in the main template. Those. in theory this should work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tema_sun, 2016-06-11
@Terras

You need a custom context_processors.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question