Reputation: 629
Is it possible in Django to have a view method associated to template, so when I {% include %} a child template in my parent template, the child template can call it's view method and get some data? Or the only way is to have a single view method associated to url that collects data for every template?
The question is not about the template inheritance. It's more about the scenario when there are a few templates included on a single page.
Upvotes: 1
Views: 155
Reputation: 20539
By default there is no way to automatically call view in django when you are using include
tag in templates.
If you want just to call some python code from inside the template, check out custom template tags. For your use case best option will be custom inclusion tag
Upvotes: 2