title: Django website sometimes doesn't print anything
body: <p>I developed a website using Django where the HTML content is scraped data from amazon. The page's function is to scrape the data from amazon when I give a search item. I used Beautiful Soup to scrape data. When I ran the function alone without running the server, the output is fine and there is no issue. But when I used that same function in my server, sometimes I get output which is a table of scraped data. But sometimes I don't get any table in my page. I feel like the issue is from the way of adding Django in my code. As I'm new to Django, please check whether I've entered all the code correctly. The code I used is,</p>
  <p>views.py</p>
  <pre><code>def amzlogic(response):
      USER_AGENT = &quot;Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36&quot;
      LANGUAGE = &quot;en-US,en;q=0.5&quot;
      session = requests.Session()
      session.headers['User-Agent'] = USER_AGENT
      session.headers['Accept-Language'] = LANGUAGE
      session.headers['Content-Language'] = LANGUAGE
      title_list = []
      price_list = []
      image_url_list = []
      
      if response.method == &quot;GET&quot;:
          search = response.GET.get(&quot;search-item&quot;)
          search = search.replace(&quot; &quot;, &quot;+&quot;)
          url = f&quot;https://www.amazon.in/s?k={search}&amp;page=1&amp;qid=1636019714&amp;ref=sr_pg_1&quot;
  
          page = requests.get(url)
          soup = BeautifulSoup(page.content,'lxml')
  
      for item in soup.select(&quot;.s-border-top&quot;):
          title = item.select_one(&quot;.a-color-base.a-text-normal&quot;).get_text()[:25]
          try:
              price = item.select_one(&quot;.a-price-whole&quot;).get_text().replace(&quot;,&quot;, &quot;&quot;).replace(&quot;.&quot;, &quot;&quot;)
          except:
              price = &quot;No Price&quot;
          image_url = item.select_one(&quot;.s-image&quot;)
  
          title_list.append(title)
          price_list.append(price)
          image_url_list.append(image_url.get('src'))
  
      return render(response, &quot;main/amazonscrape.html&quot;, {&quot;title_list&quot;:title_list, &quot;price_list&quot;:price_list, &quot;image_list&quot;:image_url_list})
  </code></pre>
  <p>templates.html</p>
  <pre><code>{% block content %}
      &lt;form method=&quot;GET&quot; action=&quot;#&quot;&gt; {%csrf_token%}
          &lt;label for=&quot;search-query&quot;&gt;Search:&lt;/label&gt; &lt;br&gt;
          &lt;input type=&quot;text&quot; name = &quot;search-item&quot; placeholder=&quot;Enter your search item&quot;&gt; &lt;br&gt;
          &lt;!-- &lt;label for=&quot;search-query&quot;&gt;Number of pages:&lt;/label&gt;&lt;br&gt;
          &lt;input type=&quot;number&quot; name = &quot;page-limit&quot; placeholder=&quot;No. of pages&quot;&gt;&lt;br&gt; --&gt;
          &lt;input type=&quot;submit&quot; name=&quot;search&quot; value=&quot;search&quot;&gt;
      &lt;/form&gt;
  
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;table&gt;
                      &lt;tbody&gt;
                          {%for title in title_list%}
                              &lt;tr&gt;
                                  &lt;td&gt;{{title}}&lt;/td&gt;
                              &lt;/tr&gt;
                          {%endfor%}
                      &lt;/tbody&gt;
                  &lt;/table&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;table&gt;
                      &lt;tbody&gt;
                          {%for price in price_list%}
                              &lt;tr&gt;
                                  &lt;td&gt;{{price}}&lt;/td&gt;
                              &lt;/tr&gt;
                          {%endfor%}
                      &lt;/tbody&gt;
                  &lt;/table&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;table&gt;
                      &lt;tbody&gt;
                          {%for image in image_list%}
                              &lt;tr&gt;
                                  &lt;td&gt;{{image}}&lt;/td&gt;
                              &lt;/tr&gt;
                          {%endfor%}
                      &lt;/tbody&gt;
                  &lt;/table&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  {%endblock%}
  </code></pre>
  <p>If the error is from someother file, please mention that in the comment. I would also add that code.</p>