html - Django - Use variables from included template -


i have following setup:

base.html

...     {% block main-content %}     {% endblock main-content %} ... 

admin.html

{% extends "base.html" %} {% load staticfiles %}  {% block main-content %}     {% include users.html %} {% endblock main-content %} 

the file users.html uses tags '{{ users }}' because renders view returns several variables. right now, if call admin.html can see template of users.html (basic html, css) without variables. don't think template rendering views.py.

is there anyway can obtain variables view returning?

note: base.html , admin.html in same django app, while users.html in different one.

thank you!

this seems common misapprehension.

templates not belong views. relationship view may (or may not) render template: template may rendered 1 or many views, , has no actual knowledge of of them. when "include" template inside admin template, there no relationship other view might render it; if need variables in view, you'll need pass them there yourself.

note sort of thing - is, including template along specific context variables - best handled inclusion tag


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -