title: creating a search bar using Django
body: <p>I have a list of markdown pages displayed on the index page. I want to make a search bar using django that displays the searched items of the list so I have written this code in order to make the search bar get a certain query</p>
  <p>in views.py:</p>
  <pre><code>def index(request):
      x = util.list_entries()
      for entryy in x:
          if 'q' in request.GET:
              q = request.GET['q']
              data = x.entryy.filter(entryy__icontains = q)
          else:
              data = x
      return render(request, &quot;encyclopedia/index.html&quot;, {
          &quot;entries&quot;: data
      })
  </code></pre>
  <p>in urls.py:</p>
  <pre><code>urlpatterns = [
      path(&quot;&quot;, views.index, name=&quot;index&quot;)]
  </code></pre>
  <p>in layout.html:</p>
  <pre><code>  &lt;form action=&quot;{% url 'index' %}&quot; method = &quot;get&quot;&gt;
                      {% csrf_token %}
                      &lt;input class=&quot;search&quot; type=&quot;search&quot; name=&quot;q&quot; placeholder=&quot;Search Encyclopedia&quot;&gt;
                  &lt;/form&gt;
  </code></pre>
  <p>util.list_entries() fuction:</p>
  <pre><code>def list_entries():
      &quot;&quot;&quot;
      Returns a list of all names of encyclopedia entries.
      &quot;&quot;&quot;
      _, filenames = default_storage.listdir(&quot;entries&quot;)
      return list(sorted(re.sub(r&quot;\.md$&quot;, &quot;&quot;, filename)
                  for filename in filenames if filename.endswith(&quot;.md&quot;)))
  </code></pre>
  <p>when I enter anything in the search bar this appears</p>
  <p>to me :</p>
  <p><a href="https://i.stack.imgur.com/tspwt.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>so what is the problem??</p>