search_results. and {{element.pk}} {{element.name}} i see just .pk what the point ?
def search(request):
if request.method == 'POST':
answer = request.POST.get('q')
print(answer)
search_results = watson.search(answer)
print(search_results)
return render(request, '1123.html', {'data': search_results,'query':answer})
return render(request, '1123.html', {'data': 'lol'})
<form action="" method="POST">
{% csrf_token %}
<input name="q" >
<input type="submit" value="Go">
</form>
{% load watson %}
{% if data %}
<ul class="search-results">
{% for search_result in data %}
<li>
{{ search_result }}
{% endfor %}
</ul>
{% endif %}
from django.apps import AppConfig
from watson import search as watson
class CoreConfig(AppConfig):
name = 'core'
def ready(self):
Good = self.get_model("Good")
watson.register(Good, field=('name','description'))
search_results = watson.filter(Good, answer)