title: Django - how to pass a value from <a href> to a view
body: <p>I have a category dropdown list in a template. I don't want to hard code it and write separate list views for each category. So is there a way to pass a value from <code>&lt;a href=""&gt;</code> to a view? I guess <code>self.request.GET.get('category search')</code> never works because there is no <code>&lt;form method="get"&gt;</code> tag. Therefor it always returns <code>None</code> due to the <code>return queryset.none()</code> statement.</p>
  
  <p><strong>home.html:</strong></p>
  
  <pre><code>&lt;div class="dropdown-menu" aria-labelledby="navbarDropdown"&gt;
      {% if all_categories %}
          {% for category in all_categories %}
              &lt;a name="category search" href="{% url 'book:category_search' category.id %}"&gt; {{ category }} &lt;/a&gt;
          {% endfor %}
      {% endif %}
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>book.urls.py:</strong></p>
  
  <pre><code>urlpatterns = [
      .........
      path('categories/&lt;int:pk&gt;', views.CategorySearchView.as_view(), name='category_search'),
  ]
  </code></pre>
  
  <p><strong>book.views.py:</strong></p>
  
  <pre><code>class CategorySearchView(generic.ListView):
  
      template_name = 'book/search.html'
      model = Book
      context_object_name = 'book_list'
      paginate_by = 100
  
      def get_queryset(self):
          queryset = super().get_queryset()
          search = self.request.GET.get('category search')
          if search:
              queryset = Book.objects.filter(categories__id=search)
              return queryset
          else:
              return queryset.none()
  </code></pre>