title: How to do SELECT MAX in Django?
body: <p>I have a list of objects how can I run a query to give the max value of a field:</p>
  
  <p>I'm using this code:</p>
  
  <pre><code>def get_best_argument(self):
      try:
          arg = self.argument_set.order_by('-rating')[0].details
      except IndexError:
          return 'no posts'
      return arg
  </code></pre>
  
  <p>rating is an integer</p>