Saturday, December 23, 2017

Re: Search results in template

FIRST, James, let me say how much I greatly appreciate you hanging in there and trying to help me.
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. 

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. 

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!



"None of you has faith until he loves for his brother or his neighbor what he loves for himself."

On Fri, Dec 22, 2017 at 4:31 PM, James Schneider <jrschneider83@gmail.com> wrote:

<blogpost start>  <article class="blogpost">  	<header>  		{% for object in object_list %}  		<h2><ahref="{{ object.get_absolute_url }}">{{ object.title }}</a></h2>  			<div class="post-info">  				<span class="post-date">  					<i class="icon-calendar"></i>  						<span class="day">{{object.chron_date}}</span>  							<span class="month">{{object.clock}} </span>  	</span>  <span class="submitted"><i class="icon-user-1"></i> by <a href="#"></a></span>  <span class="comments"><i class="icon-chat"></i> <a href="#">22 comments</a></span>  									</div>  	</header>  		<div class="blogpost-content">  			{{ object.content|truncatewords:30 }}</div>  				<footer class="clearfix">  					<div class="tags pull-left"><i class="icon-tags"></i> <a href="#">tag 1</a>, <a href="#">tag 2</a>, <a href="#">long tag 3</a></div>  	<div class="link pull-right"><i class="icon-link"></i><a href="{{ object.get_absolute_url }}">Read More</a></div>  				</footer>  </article>  		<!-- blogpost end-->  		{% endfor %}    Any assistance in getting the search results to show up greatly appreciated.  --

There is still an issue with the HTML from what I can see, your {% for %} loop starts within an <article> tag, but the </article> tag is within the {% for %} loop, so you are trying to create multiple article entries, but only the first has an opening <article> tag. Not sure how/if that affects the display of the results.

The point from my previous goof still stands, do your results show within the rendered page HTML, but just aren't being displayed?

-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%2BciV56ORGwDeap7nser4RwSE3gdZVXPgREMU%3Dzw8g6YDx2g%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
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/CAKd6oBwLFd01KC%2BP_9-f5x4zPPcZP_HWG6wp678MPEKO5GQSZg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment