B
B
Boldy2014-12-02 09:49:58
Django
Boldy, 2014-12-02 09:49:58

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)

The templates are also about the same:
{% 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

1 answer(s)
A
alternativshik, 2014-12-02
@Boldy

Well, maybe there is an empty kveriset in the products?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question