Sonly for two fields and custom display results

30 views
Skip to first unread message

Дмитро Зелінський

unread,
Mar 10, 2016, 2:29:34 PM3/10/16
to django-watson discussion group
Hi i have some problem with yours lib. The first is little documentation.
So i wanna make search just about two columns name and description but filed = (....) nothing change.
And  when  i want to display results like   {%for  element in data %} data is search_results. and {{element.pk}} {{element.name}} i see just .pk what the point ?


i  have views.
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'})


and template.html

<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 %}

my config file form other app
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'))



Дмитро Зелінський

unread,
Mar 11, 2016, 2:31:09 AM3/11/16
to django-watson discussion group
All problem was in my views.py      
   search_results = watson.filter(Good, answer)




четвер, 10 березня 2016 р. 21:29:34 UTC+2 користувач Дмитро Зелінський написав:
Reply all
Reply to author
Forward
0 new messages