PyCharm had my project running in a separate process. Don't worry about that. I don't think it's a huge issue
😪
I have the right view
The template context says I have a queryset
The explanation seems right.
And so does the selection
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
##########
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.
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.
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.
"None of you has faith until he loves for his brother or his neighbor what he loves for himself."
On Sun, Dec 24, 2017 at 2:44 AM, James Schneider <jrschneider83@gmail.com> wrote:
--On Dec 23, 2017 5:36 PM, "Malik Rumi" <malik.a.rumi@gmail.com> wrote:FIRST, James, let me say how much I greatly appreciate you hanging in there and trying to help me.No worries.2nd, as to your two points about the html:a. This template, serp_list.html, is identical to ktab_list.html, except that serp_list has the title 'SEARCH' at the top and some bolierplate text about this being the search results page. Other than that they are identical, including the template for loop.serp_list is supposed to be called by localhost/serp/, which points to views.serp, which is an FBV.ktab_list is a vanilla implementation of ListView, called by localhost/index/, and it shows all Entry objects as you would expect.The header you see is the blog post header, ie, this is where the title and the get absoulte url to the detail page is supposed to go. On /index/ that works like it should. On serp, well, that's why I am here.b. Your second point is probably well taken, that the for loop should completely wrap the article, and that might explain why the author and comments part of the last three posts were not the same font as the first post. I have changed that in the html, but it has not changed the result.Hooray, at least I've gotten something right. ;-3rd, just because things weren't complicated enough, now I am getting inconsistent results. Whereas before I got views.serp called, a db query with 4 results, on the right template, now I am getting a value error ('returns None' - how's that for a news flash?). The only difference is that I downloaded the free version of pycharm to see if their visual debugger would help me. So calling the page through pycharm, instead of the regular terminal, is the only difference, and I don't think that should make a difference. But either way, I still have no result on my page - and oh yea, pycharm says the same thing my print statements did - that the query was there and pulled up the expected objects. They just won't show up on the template.Confused. You mentioned PyCharm affected the results but then indicated the same results?4th, I don't know how relevant this is, but the form which created the search box has the form action = '/serp/', but despite that, if I use the search box in /index/, I stay on /index/ and just get the query attached to the end of that url, rather than /serp/ plus the query. I have to manually type in /serp/ to get views.serp called. When it stays on /index/ plus the query, the result shown are just Entry.objects.all(), as you would expect on a ListView. Any thoughts on that? Is it related? Why isn't my form action working? THANKS!A few (possibly dumb) questions:Have you verified that the serp.html page is the one actually being rendered? DDT can verify this.Have you confirmed the context being provided to the template actually contains the variables and query results you are expecting? DDT can also verify this.Can you do something simple like {{ object_list }} in your template just to see if anything is printed? When doing quick troubleshooting I like to do this:|{{ object_list }}|That way if I see || in the template (and source), I know the variable is empty.Do you have any non-standard middleware or template context processors enabled?Are your forms set to use a method of GET or POST? Sounds like GET but just want to verify.When you are on /index/ and you search, does the runserver console show a hit against /serp/ (per the form action) or is it simply a hit against /index/ again? Or is there a redirect for some reason?-James
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/ .xSW1BjLXXSQ/unsubscribe
To unsubscribe from this group and all its topics, send an email to django-users+unsubscribe@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% .2BciX3a% 3D3O9AGv4hF5bff0xD7L8mCrkrrW0n KvRtNCzZ3UxQ%40mail.gmail.com
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+unsubscribe@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/CAKd6oByeBCGFejVOhCRddxfep%2BYX52ixzzAZU__Uq1C-Qy_XEw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment