R
R
Ruslan Bergutov2015-05-12 06:27:42
Django
Ruslan Bergutov, 2015-05-12 06:27:42

How to display two variables at once in a django template?

How can I display two views at once in a template? the context processor will not work, right now I'm looking at the template tag, in what cases is it needed at all? Or does it not work either?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
zelsky, 2015-05-12
@zelsky

var1 = Model1.objects.all()
var2 = Model2.objects.all()
context = { 'var1':var1 , 'var2': var}

render (request,"index.html", context)

M
marazmiki, 2015-05-12
@marazmiki

A dictionary is passed to the template context, the keys of which are the variables. A view, a template tag, and even a context processor are perfect.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question