title: Django1.4: How to use order_by in template?
body: <p>Django1.4: How to use order_by in template?</p>
  
  <p>models.py</p>
  
  <pre><code>from django.db import models
  from django.contrib.auth.models import User
  from django.contrib.contenttypes.models import ContentType
  from django.contrib.contenttypes import generic
  
  class Note(models.Model):
      contents = models.TextField()
      writer = models.ForeignKey(User, to_field='username')
      date = models.DateTimeField(auto_now_add=True)
  
      content_type = models.ForeignKey(ContentType)
      object_id = models.PositiveIntegerField()
      content_object = generic.GenericForeignKey('content_type', 'object_id')
  
  
  class Customer(models.Model):
      name = models.CharField(max_length=50,)
      notes = generic.GenericRelation(Note, null=True)
  </code></pre>
  
  <p>Above is my models.py.</p>
  
  <p>I want to use 'order_by'(<a href="https://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by" rel="noreferrer">https://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by)</a></p>
  
  <p>And...</p>
  
  <p>views.py</p>
  
  <pre><code>from django.views.generic import DetailView
  from crm.models import *
  
  class customerDetailView(DetailView):
      context_object_name = 'customerDetail'
      template_name = "customerDetail.html"
      allow_empty = True
      model = Customer
      slug_field = 'name'
  </code></pre>
  
  <p>My views.py use DetailView(<a href="https://docs.djangoproject.com/en/1.4/ref/class-based-views/#detailview" rel="noreferrer">https://docs.djangoproject.com/en/1.4/ref/class-based-views/#detailview</a>).</p>
  
  <p>And</p>
  
  <p>customerDetail.html</p>
  
  <pre><code>&lt;table class="table table-bordered" style="width: 100%;"&gt;
      &lt;tr&gt;
          &lt;td&gt;Note&lt;/td&gt;
      &lt;/tr&gt;
      {% for i in customerDetail.notes.all.order_by %}&lt;!-- It's not working --&gt;
          &lt;tr&gt;
              &lt;th&gt;({{ i.date }}) {{ i.contents }}[{{ i.writer }}]&lt;/th&gt;
          &lt;/tr&gt;
      {% endfor %}
  &lt;/table&gt;
  </code></pre>
  
  <p>I want to use order_by in template...</p>
  
  <p>What should I do?</p>