title: Search Functionality on a Django Site
body: <p>I'm trying to add a search function to my website but I'm having some issues. It's currently telling me that "Search" is not defined, but I have the class in my views file. This is what I have thus far:</p>
  
  <p>urls.py</p>
  
  <pre><code>from django.conf.urls import url
  from . import views
  
  urlpatterns = [
      url(r'^$', views.home, name='home'),
      url(r'^player/(?P&lt;pk&gt;\d+)/$', views.player, name='player'),
      url(r'^season/(?P&lt;pk&gt;\d+)/$', views.season, name='season'),
      url(r'^seasons/$', views.seasons, name='seasons'),
      url(r'^search/$', Search.as_view(), name='search'),
  ]
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>from django.shortcuts import render, get_object_or_404, redirect
  from django.views.generic import ListView
  from .models import Player, Season, PxS, Statistics
  
  def home(request):
      seasons = Season.objects.order_by('sid')
      return render(request, 'webapp/home.html', {'seasons': seasons})
  
  def player(request, pk):
      player = get_object_or_404(Player, pk=pk)
      return render(request, 'webapp/player.html', {'player': player, 'seasons': player.season_set.order_by('sid'), 'statistics': player.statistics_set.all()})
  
  def season(request, pk):
      season = get_object_or_404(Season, pk=pk) 
      return render(
          request, 
          'webapp/season.html',
          {'season': season, 'players': season.players.order_by('lastname')}
      )
  
  def seasons(request):
      seasons = Season.objects.order_by('sid')
      return render(request, 'webapp/seasons.html', {'seasons': seasons})
  
  class Search(ListView):
      template_name = 'search.html'
      model = Player
      context_object_name = 'list'
  
      def get_context_data(self, **kwargs):
          context = super(Search, self).get_context_data(**kwargs)
          context['count'] = self.get_queryset().count()
          return context
  
      def get_queryset(self):
          pobj = Player.objects.all()
          var_get_search = self.request.GET.get('search_box')
          var_get_order_by = self.request.GET.get('pid')
  
          if var_get_search is not None:
              pobj = pobj.filter(playername__icontains=var_get_search)
  
          if var_get_order_by is not None:
              pobj = pobj.order_by(var_get_order_by)
  
          return pobj
  </code></pre>
  
  <p>Any insight is greatly appreciated. I'm kind of just piecing this stuff together little by little. Thanks!</p>