Answer the question
In order to leave comments, you need to log in
Why doesn't the django template see the variable?
There are two methods in views that work in the same way. Only one succeeds in passing the variable to the context, while the other does not. What am I doing wrong? The template itself is displayed normally, but does not see the variable.
#работает
def faq_page(request):
template = 'html/faq.html'
context = Context({'faqs': Question.objects.all(), })
return render_to_response(template, context)
# не работает
def products_page(request):
template = 'html/catalog.html'
context = Context({'products': Product.objects.all(), })
return render_to_response(template, context)
{% for faq in faqs %}
<p class="question">{{ faq.question }}</p>
<p class="answer">{{ faq.answer }}</p>
{% endfor %}
{% for product in products %}
<p>{{ product.name }}</p>
{% endfor %}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question