The template context says I have a queryset

I see it there. Can you post up the model for Entry?




And so does the selection


Yes. It appears that you will have 4 results in your queryset.



I put print statements in the view:

##########
Quit the server with CONTROL-C.
This is the value of query:  SearchQuery(eaa)
This is the value of QuerySet:  <QuerySet [('2017-10-09 Incentive, a
further review', 0.151982), ('2017-11-14  Pulling The Trigger', 0.151982),
('2017-10-05 A Failure of Incentive?', 0.121585), ('2017-10-20 spider
refactor', 0.121585)]>
[26/Dec/2017 18:57:31] "GET /serp/?q=eaa HTTP/1.1" 200 66580

##########


At this point, the view doesn't appear to be the problem. We need to start
tracking things down in the template code.




Note this is all done through my simple html search form, defined in the
template. My Django Form, SearchBox(), does absolutely nothing, as if it
isn't connected to anything. I don't understand what the problem there is,
I can't show that this is related or not. I do know I'd rather have the
functionality than a pretty form.


No reason you can't have both, but let's work on the result display issue
first.

An ordinary ListView of all objects works normally, as does my DetailView.
I have tried several times to re-write views.serp as a cbv with
get_context_data, but either context or request or Searchbox() end up being
undefined, or an ImportError.


Are you overriding get_context_data() correctly? It doesn't sound like it.


Finally, a screenshot of my search page, with four spaces for the 4 entries
that correctly correspond to the query 'eaa'. They just aren't there.


This is where the problem is, I think.

You should set up a simple loop in your template:

<ul>
{% for obj in QuerySet %}
<li>{{obj}}</li>
{% empty %}
<li>No results</li>
{% endfor %}

If that works, you should go deeper per your Entry model:


<ul>
{% for obj in QuerySet %}
<li>{{obj.name}}: {{obj.weight}}</li>
{% empty %}
<li>No results</li>
{% endfor %}

I'm using name and weight as an attribute of Entry, but you should use
something that matches your model definition. I think the issue is that you
are not referring to your model correctly within the search results within
the template.

-James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciWvgD7-RnqWJvpKrpYvd2SB2TGwOW2bj4UOcKbtMJVR%3Dg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to