title: Django-Haystack - How to sort using get parameters?
body: <p>I need to be able to sort data from the index like this:</p>
  
  <pre><code>http://mywebapp.com/search/?q=something&amp;sort_by=points-desc
  </code></pre>
  
  <p>In other words, I need to pass the value of "sort_by" in the URL. I've trying to search on the documentation but I can't find any example.</p>
  
  <p>Can someone give m a clue on how to achieve this?</p>
  
  <p>I'm using Django Haystack 2.0 and the SearchView()</p>
  
  <p>Any clues?</p>
  
  <hr>
  
  <p>Update: Haystack Search Indexes</p>
  
  <pre><code>class LinkViewIndex(indexes.SearchIndex, indexes.Indexable):
      text = indexes.CharField(document=True, use_template=True)
      section = indexes.CharField(model_attr='section')
      section_id = indexes.CharField(model_attr='section_id')
      item_author_username = indexes.CharField(model_attr='item_author_username')
      title = indexes.CharField(model_attr='title')
      url = indexes.CharField(model_attr='url')
      url_image = indexes.CharField(model_attr='url_image')
      comments = indexes.CharField(model_attr='comments', null=True)
      comments_count = indexes.CharField(model_attr='comments_count')
      points = indexes.CharField(model_attr='points')
      date_inserted = indexes.DateTimeField(model_attr='date_inserted')
  
      def get_model(self):
      return LinkView
  
      def index_queryset(self, using=None):
      """Used when the entire index for model is updated."""
      return self.get_model().objects.filter(date_inserted__lte=datetime.datetime.now())  
  
  
  class TextViewIndex(indexes.SearchIndex, indexes.Indexable):
      text = indexes.CharField(document=True, use_template=True)
      section = indexes.CharField(model_attr='section')
      section_id = indexes.CharField(model_attr='section_id')
      item_author_username = indexes.CharField(model_attr='item_author_username')
      title = indexes.CharField(model_attr='title')
      texto = indexes.CharField(model_attr='texto')
      comments = indexes.CharField(model_attr='comments', null=True)
      comments_count = indexes.CharField(model_attr='comments_count')
      points = indexes.CharField(model_attr='points')
      date_inserted = indexes.DateTimeField(model_attr='date_inserted')
  
      def get_model(self):
      return TextView
  
      def index_queryset(self, using=None):
      """Used when the entire index for model is updated."""
      return self.get_model().objects.filter(date_inserted__lte=datetime.datetime.now())  
  
  
  class OffTopicLinkViewIndex(indexes.SearchIndex, indexes.Indexable):
      text = indexes.CharField(document=True, use_template=True)
      section = indexes.CharField(model_attr='section')
      section_id = indexes.CharField(model_attr='section_id')
      item_author_username = indexes.CharField(model_attr='item_author_username')
      title = indexes.CharField(model_attr='title')
      url = indexes.CharField(model_attr='url')
      url_image = indexes.CharField(model_attr='url_image')
      comments = indexes.CharField(model_attr='comments', null=True)
      comments_count = indexes.CharField(model_attr='comments_count')
      points = indexes.CharField(model_attr='points')
      date_inserted = indexes.DateTimeField(model_attr='date_inserted')
  
      def get_model(self):
      return OffTopicLinkView
  
      def index_queryset(self, using=None):
      """Used when the entire index for model is updated."""
      return self.get_model().objects.filter(date_inserted__lte=datetime.datetime.now()) 
  
  
  class OffTopicTextViewIndex(indexes.SearchIndex, indexes.Indexable):
      text = indexes.CharField(document=True, use_template=True)
      section = indexes.CharField(model_attr='section')
      section_id = indexes.CharField(model_attr='section_id')
      item_author_username = indexes.CharField(model_attr='item_author_username')
      title = indexes.CharField(model_attr='title')
      texto = indexes.CharField(model_attr='texto')
      comments = indexes.CharField(model_attr='comments', null=True)
      comments_count = indexes.CharField(model_attr='comments_count')
      points = indexes.CharField(model_attr='points')
      date_inserted = indexes.DateTimeField(model_attr='date_inserted')
  
      def get_model(self):
      return OffTopicTextView
  
      def index_queryset(self, using=None):
      """Used when the entire index for model is updated."""
      return self.get_model().objects.filter(date_inserted__lte=datetime.datetime.now()) 
  
  
  class BusinessLinkViewIndex(indexes.SearchIndex, indexes.Indexable):
      text = indexes.CharField(document=True, use_template=True)
      section = indexes.CharField(model_attr='section')
      section_id = indexes.CharField(model_attr='section_id')
      item_author_username = indexes.CharField(model_attr='item_author_username')
      title = indexes.CharField(model_attr='title')
      country = indexes.CharField(model_attr='country')
      localidades = indexes.CharField(model_attr='localidades')
      url = indexes.CharField(model_attr='url')
      url_image = indexes.CharField(model_attr='url_image')
      comments = indexes.CharField(model_attr='comments', null=True)
      comments_count = indexes.CharField(model_attr='comments_count')
      points = indexes.CharField(model_attr='points')
      date_inserted = indexes.DateTimeField(model_attr='date_inserted')
  
      def get_model(self):
      return BusinessLinkView
  
      def index_queryset(self, using=None):
      """Used when the entire index for model is updated."""
      return self.get_model().objects.filter(date_inserted__lte=datetime.datetime.now()) 
  
  
  class BicycleAdViewIndex(indexes.SearchIndex, indexes.Indexable):
      text = indexes.CharField(document=True, use_template=True)
      section = indexes.CharField(model_attr='section')
      section_id = indexes.CharField(model_attr='section_id')
      item_author_username = indexes.CharField(model_attr='item_author_username')
      title = indexes.CharField(model_attr='title')
      country = indexes.CharField(model_attr='country')
      city = indexes.CharField(model_attr='city')
      n_item_kind = indexes.CharField(model_attr='n_item_kind')
      n_bicycle_ad_condition = indexes.CharField(model_attr='n_bicycle_ad_condition')
      bicyclead_link_url = indexes.CharField(model_attr='bicyclead_link_url', null=True)
      bicyclead_link_url_image = indexes.CharField(model_attr='bicyclead_link_url_image', null=True)
      bicyclead_insite_image = indexes.CharField(model_attr='bicyclead_insite_image', null=True)    
      texto = indexes.CharField(model_attr='texto', null=True)
      telephone = indexes.CharField(model_attr='telephone', null=True)
      price = indexes.CharField(model_attr='price', null=True)
      n_bicycle_ad_payment_type = indexes.CharField(model_attr='n_bicycle_ad_payment_type', null=True)
      propriedades = indexes.CharField(model_attr='propriedades', null=True)
      comments = indexes.CharField(model_attr='comments', null=True)
      comments_count = indexes.CharField(model_attr='comments_count')
      points = indexes.CharField(model_attr='points')
      date_inserted = indexes.DateTimeField(model_attr='date_inserted')
  
      def get_model(self):
      return BicycleAdView
  
      def index_queryset(self, using=None):
      """Used when the entire index for model is updated."""
      return self.get_model().objects.filter(date_inserted__lte=datetime.datetime.now()) 
  </code></pre>
  
  <p>The question should be. How can I pass the GET parameter to order by "points" or "date_inserted" using something like this:</p>
  
  <pre><code>http://mywebapp.com/search/?q=something&amp;sort_by=points-desc
  </code></pre>