Haystack 2.1 with tables2 (Dev 0.16) is currently used to manage queries using Elastisearch. When I try to search, I get the following error message: Expected table or query, not "str". Details here
In the template C: \ RealPython \ quorum \ templates \ search \ search.html there is an error on line 20 The expected table or query, not "str".
10 <td> </td> 11 <td> 12 <input type="submit" value="Search"> 13 </td> 14 </tr> 15 16 </table> 17 18 {% if query %} 19 <h3>Results</h3> 20 {% render_table table %} 21 {% for result in page.object_list %} 22 <p> 23 24 <a href="{{ result.object.get_absolute_url }}">{{ result.object.Inducer_Name_Synonym_Abbreviation }}</a> 25 </p> 26 27 {% empty %} 28 29 {% endfor %} 30
My views.py code is here:
def report(request, template='search/search.html', load_all=True, form_class=ModelSearchForm, searchqueryset=None, context_class=RequestContext, extra_context=None, results_per_page=None): table = '' query = '' results = EmptySearchQuerySet() if request.GET.get('q'): form = form_class(request.GET, searchqueryset=SearchQuerySet().models(Quorum_Sensing), load_all=load_all) if form.is_valid(): query = form.cleaned_data['q'] results = form.search() pklist = [r.pk for r in results] table = QuorumTable(Quorum_Sensing.objects.filter(pk__in=pklist)) RequestConfig(request).configure(table) else: form = form_class(searchqueryset=searchqueryset, load_all=load_all) context = { 'form': form, 'table': table, } return render(request, template, context) def quorum_list(request): quorum_list = QuorumTable(Quorum_Sensing.objects.filter(pk=1)) RequestConfig(request).configure(quorum_list) return render(request, 'simple_list.html', {"quorum_list": Quorum_Sensing.objects.all()})
How to fix this error message? I use the latest tables2 with Django 1.62.
Thank you in advance for your help!
source share