title: Sorting a Django QuerySet by a property (not a field) of the Model
body: <h2>Some code and my goal</h2>
  
  <p>My (simplified) model:</p>
  
  <pre><code>class Stop(models.Model):
      EXPRESS_STOP = 0
      LOCAL_STOP   = 1
  
      STOP_TYPES = (
          (EXPRESS_STOP, 'Express stop'),
          (LOCAL_STOP, 'Local stop'),
      )
  
      name = models.CharField(max_length=32)
      type = models.PositiveSmallIntegerField(choices=STOP_TYPES)
      price = models.DecimalField(max_digits=5, decimal_places=2, null=True, blank=True)
  
      def _get_cost(self):
          if self.price == 0:
              return 0
          elif self.type == self.EXPRESS_STOP:
              return self.price / 2
          elif self.type == self.LOCAL_STOP:
              return self.price * 2
          else:
              return self.price    
      cost = property(_get_cost)
  </code></pre>
  
  <p><strong>My Goal</strong>: I want to sort by the <code>cost</code> property. I tried two approaches.</p>
  
  <h2>Using order_by QuerySet API</h2>
  
  <pre><code>Stops.objects.order_by('cost')
  </code></pre>
  
  <p>That yielded the following template error:</p>
  
  <pre><code>Caught FieldError while rendering: Cannot resolve keyword 'cost' into field.
  </code></pre>
  
  <h2>Using dictsort template filter</h2>
  
  <pre><code>{% with deal_items|dictsort:"cost_estimate" as items_sorted_by_price %}
  </code></pre>
  
  <p>Received the following template error:</p>
  
  <pre><code>Caught VariableDoesNotExist while rendering: Failed lookup for key [cost] in u'Union Square'
  </code></pre>
  
  <h2>So...</h2>
  
  <p>How should I go about doing this?</p>