title: Django List View Sorting Bulletins
body: <p>I have a ListView of bulletins I am trying to provide ordering options for. I am using a dropdown to pass a URL parameter called <code>sortBy</code>.</p>
  <p>I have confirmed via my print statement at the end of <code>def get(self, request):</code> that the order of the <code>queryset</code> changes as expected when different values are passed to <code>sortBy</code>.</p>
  <p>The problem I am facing is that even though the order of the <code>queryset</code> is changing as expected, this is not being reflected in <code>myTemp.html</code>. The order of the bulletins being displayed are not changing even though the order of the <code>queryset</code> is.</p>
  <p>What is causing this behavior?</p>
  <p><strong>Views.py</strong></p>
  <pre><code>@method_decorator(login_required, name='dispatch')
  class BulletinList(ListView):
      model = Bulletin_VW
      template_name = 'myTemp.html'
      context_object_name = 'bulletins'
      additional_context = {}
  
      @method_decorator(login_required)
      def dispatch(self, *args, **kwargs):
          return super().dispatch(*args, **kwargs)
  
      def get_queryset(self):
          queryset = Bulletin_VW.objects.filter(store_id=self.additional_context['storeID'],
                                                     entity_id=self.additional_context['entityID'])
          ordering = self.get_ordering()
          queryset = queryset.order_by(ordering)
          return queryset
  
      def get_context_data(self, *args, **kwargs):
          self.object_list = self.get_queryset()
          context = super(BulletinList, self).get_context_data(*args, **kwargs)
          context.update(self.additional_context)
          return context
  
      def get_ordering(self):
          ordering = self.request.GET.get('sortBy', 'Name')
          sortDict = {'Name': 'author', 'Date-Newest': '-capture_date', 'Date-Oldest': 'capture_date'}
          ordering = sortDict.get(ordering)
          return ordering
  
      def get(self, request):
          if not validate_user_session(request.user.id):
              return redirect('newSession')
          currentSession = Current_Session_VW.objects.filter(user_id=request.user.id)[0]
          storeID = currentSession.store_id
          entityID = currentSession.entity_id
          entStore = currentSession.entity_store_name
          balance = get_balance(storeID, entityID)
          self.additional_context['add1'] = add1
          self.additional_context['add2'] = add2
          self.additional_context['add3'] = add3
          self.additional_context['add4'] = add4
          self.additional_context['sys_bulletins'] = Bulletin_System_VW.objects.all()
          self.additional_context['add5'] = add5
          print(self.get_context_data())
          return render(request, 'myTemp.html', self.get_context_data())
  </code></pre>
  <p><strong>myTemp.html excerpt</strong></p>
  <pre><code>    {% for bulletin in bulletins %}
      &lt;div class=&quot;row&quot;&gt;
          &lt;div class=&quot;col-sm-12&quot;&gt;
          &lt;article class=&quot;media content-section&quot;&gt;
            &lt;div class=&quot;media-body&quot;&gt;
              &lt;div class=&quot;article-metadata&quot;&gt;
                &lt;a class=&quot;mr-2&quot; href=&quot;#&quot;&gt;{{ bulletin.author }}&lt;/a&gt;
                &lt;small class=&quot;text-muted&quot;&gt;{{ bulletin.capture_date|date:&quot;F d, Y&quot; }}&lt;/small&gt;
              &lt;/div&gt;
              &lt;h2&gt;&lt;a class=&quot;article-title&quot; href=&quot;{% url 'bulletin-detail' bulletin.bulletin_entity_store_id %}&quot;&gt;{{ bulletin.title }}&lt;/a&gt;&lt;/h2&gt;
              &lt;p class=&quot;article-content&quot;&gt;{{ bulletin.content }}&lt;/p&gt;
            &lt;/div&gt;
          &lt;/article&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      {% endfor %}
  </code></pre>