title: How to Pass option from search into url
body: <p>Currently i have a search that returns models matching the input. My goal is to add a dropdown to this search and pass that into the url for the use of separate views in one template.</p>
  
  <p>So my search form would look like this </p>
  
  <p>index.html</p>
  
  <pre><code>&lt;form method="GET" action = "{% url 'app:search' %}"&gt;
   &lt;input  name="q" type="text" placeholder="search by Key or Name"/&gt;
   &lt;select name = "category"&gt;
       &lt;option value = "1"&gt; Category 1&lt;/option&gt;
       &lt;option value = "2"&gt; Category 2&lt;/option&gt;
       &lt;option value = "all"&gt; All&lt;/option&gt;
   &lt;/select&gt;
    &lt;input  type="submit" value="Search"/&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>I need my urls to look something like this </p>
  
  <p>urls.py </p>
  
  <pre><code>app_name = 'app'
  urlpatterns = [
          path('login/index/', views.IndexView.as_view()),
          path('login/index/&lt;category option here&gt;/search', views.SearchView.as_view(), name="search"),
          path('login/index/&lt;category option here&gt;/&lt;slug:key&gt;', views.ModelView.as_view(), name="detail"),  
      ]
  </code></pre>
  
  <p>I am able to grab the <code>key</code> and push that to the url on the search results page no problem like this </p>
  
  <p>search.html</p>
  
  <pre><code>&lt;ul&gt;
      {% for x in results %}
      &lt;li&gt;&lt;a href = "{% url 'app:detail' x.key %}"&gt;{{x.name}}&lt;/a&gt;&lt;/li&gt;
      {% endfor %}
  &lt;/ul&gt;
  </code></pre>
  
  <p>And able to grab the key by using a get function like so in my views</p>
  
  <pre><code>def get(self, request, *args, **kwargs):
      self.q = self.kwargs['key']
      return super().get(request, *args, **kwargs)
  </code></pre>
  
  <p>But since category isnt part of this model's schema i cannot use this same approach(theres a complicated reason as to why it isnt)</p>
  
  <p><strong>OVERALL</strong></p>
  
  <p>I need to carry on the category option selected from the IndexView into the ModelView and be able to use that in my templates to create different pages like i have below, and hopefully use a <code>GET</code> function in my view to access the category and return context that gives me the category</p>
  
  <pre><code>&lt;% if category == "1" %&gt;
     &lt;h1&gt; CATEGORY 1 &lt;/h1&gt;
  
  &lt;% elseif category == "2" %&gt;
     &lt;h2&gt; CATEGORY 2 &lt;/h1&gt;
  </code></pre>
  
  <p>EDIT: 
  views.py</p>
  
  <pre><code>class SearchView(LoginRequiredMixin, TemplateView):
      template_name = 'app/search.html'
  
      def get(self, request, *args, **kwargs):
          q = request.GET.get('q','')
          for term in list(set(q.split())):
              self.results = Model1.objects.filter(Q(name__icontains= term) | Q(key__icontains=term))
          return super().get(request, *args, **kwargs)
  
      def get_context_data(self, **kwargs):
          context = super(SearchView, self).get_context_data(**kwargs)
          context['results'] = self.results
          return context
  </code></pre>