title: Creating an auction model a la eBay max bid style
body: <p>I'm trying to work with a few concepts of auction house style models, right now I have an <code>Auction</code> model and a <code>Bid</code> model.  The two relate through a ForeignKey in the <code>Bid</code> model, with <code>Bid.amount</code> containing the amount that a user has bid.</p>
  
  <p>I already utilise the ordering on the <code>Bid.amount</code> field to define the highest bid, but I was wondering if there is a simple way to define a <code>max_bid</code> and the output to the user is what looks like a "smart bidding" system, a la eBay.</p>
  
  <p>So say if the following applies</p>
  
  <pre><code>$ bid1 = 9000  # max bid for bid1 object
  $ bid2 = 6000  # max bid for bid2 object
  $ bid3 = 9500  # max bid for bid3 object
  $ starting_price = 5000  # starting price for the auction
  </code></pre>
  
  <p>When bid1 is placed (indicating that the highest the smart bid should go up to is 9000) the current auction price should remain at 5000, as there are no other bids on the item.</p>
  
  <p>When bid2 is placed, the current auction price should then increase to 6001 (as bid1 is still higher)</p>
  
  <p>When bid3 is placed, the current auction price should then increase to 9001 (outbidding bid1, and becoming the current highest bidder).</p>
  
  <p>if anyone has any ideas of the best way to tackle this, I'd love to hear them.</p>
  
  <p>Edit: my models, for reference</p>
  
  <pre><code>class Auction(models.Model):
      seller = models.ForeignKey(User)
      item_id = models.CharField(max_length=255, blank=True, null=True)
      item_name = models.CharField(max_length=255, blank=True, null=True)
      winner = models.ForeignKey(User, related_name='Auction_Winner', blank=True, null=True)
      reserve = models.CharField(max_length=255, blank=True, null=True)
      is_guildbank_sale = models.BooleanField(default=True)
      created = models.DateTimeField(editable=False, null=True)
      expires = models.DateTimeField(editable=False, null=True)
  
  def __unicode__(self):
      return '%s selling %s' % (self.seller, self.item_name)
  
      def save(self, *args, **kwargs):
          ''' On save, update timestamps '''
          if not self.id:
              self.created = datetime.today()
          self.expires = datetime.today() + timedelta(days=3)
          return super(Auction, self).save(*args, **kwargs)
  
  
  class Bid(models.Model):
      auction = models.ForeignKey(Auction, null=True)
      user = models.ForeignKey(User, related_name='bid_owner', null=True)
      bid_amount = models.IntegerField(blank=True, null=True)
  
      class Meta:
          verbose_name = "Auction Bid"
          verbose_name_plural = "Auction Bids"
          ordering = ['-bid_amount',]
          get_latest_by = 'bid_amount'
  </code></pre>