title: Converting codes from FBV to CBV in Django Views
body: <p>I'm currently converting my function-based views to class-based views.  On my template, I get a value through the <code>input</code> tag.</p>
  
  <pre><code>&lt;input name="search_text" type="text"&gt;
  </code></pre>
  
  <p>After getting the value, I process with the value like the following in FBV.</p>
  
  <pre><code>def search(request):
      search_text = request.GET.get('search_text')
  
      search_stores = Store.objects.filter(Q(businessName__icontains=search_text) | Q(mKey__icontains=search_text))
  </code></pre>
  
  <p>But now, I wanna convert the codes to CBV.
  How can I do that?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <pre><code>def search(request):
      search_text = request.GET.get('search_text')
      sorter = request.GET.get('sorter')
  
      if not sorter:
          sorter = 'popularity'
  
      if search_text:
          search_stores = Store.objects.filter(Q(businessName__icontains=search_text) | Q(mKey__icontains=search_text))
          if sorter == 'businessName':
              search_stores = search_stores.order_by(sorter)
          else:
              search_stores = search_stores.order_by(sorter).reverse()
      else:
          search_stores = ''
  
      for store in search_stores:
          store.mKey = store.mKey.split(' ')
  
      return render(request, 'boutique/search.html', {
          'search_stores': search_stores,
          'search_text': search_text,
          'sorter': sorter,
      })
  </code></pre>