[Answered ]-Django: how to use a queryset and display results in a template?

2👍

Your problem is that you are accessing to q1 in template, and it is your complete QuerySet, it is not an single object. I think this should work:

q1 = labels.objects.filter(label_number="1", label_type="B")

return render(request, 'frontend/base_home.html', {'q1' : q1})

And then in your template:

{% for q in q1 %}

    {{ q.label_desc_fr }}

{% endfor %}
👤Gocht

Leave a comment