Поиск в базе данных по имени с множественным возвратом. django
Здравствуйте ребята, я создаю инструмент поиска для postgres в django и получаю много ошибок, мой вывод выглядит следующим образом. <QuerySet [<Bindll: ВИЧ-1 протеаза>, <Bindll: ВИЧ-1 протеаза>, <Bindll: ВИЧ-1 протеаза>
мой код такой
#Search resuts page.
{% extends 'Search/base.html' %}
{%block content %}
<center>
<br/><br/><br/><br/>
<h1>{% if ChemSearched %}
{{ChemSearched}}
<br>
<br>
{% for Bindll in tarname %}
{{tarname}}<br>
{% endfor %}
</h1></strong>
{% else %}
<strong>No Entry</strong>
{% endif %}
Copyright (c)
</center>
{% endblock %}
Имя моей базы данных в Bindll.
#Views.py page
from django.shortcuts import render
from django.http import HttpResponseRedirect
from .models import Bindll
def search_result(request):
if request.method == "POST":
ChemSearched = request.POST.get('ChemSearched')
tarname = Bindll.objects.filter(targetnameassignedbycuratorordatasource__contains=ChemSearched)
return render(request, 'Search/search_result.html',
{'ChemSearched':ChemSearched,'tarname':tarname})
else:
return render(request, 'Search/search_result.html',{})
использую Postgresql и gitbash, если это связано. Заранее спасибо.
В forloop
необходимо получить доступ к итерируемой переменной, а не к фактическому контексту
{% for Bindll in tarname %}
{{Bindll}}<br>
{% endfor %}