title: Django post_save() signal implementation
body: <p>I have a question about django.</p>
  
  <p>I have ManyToMany Models here</p>
  
  <pre><code>class Product(models.Model):
       name = models.CharField(max_length=255)
       price = models.DecimalField(default=0.0, max_digits=9, decimal_places=2)
       stock = models.IntegerField(default=0)
  
       def  __unicode__(self):
           return self.name
  
  class Cart(models.Model):
      customer = models.ForeignKey(Customer)
      products = models.ManyToManyField(Product, through='TransactionDetail')
      t_date = models.DateField(default=datetime.now())
      t_sum = models.FloatField(default=0.0)
  
      def __unicode__(self):
           return str(self.id)
  
  class TransactionDetail(models.Model):
      product = models.ForeignKey(Product)
      cart = models.ForeignKey(Cart)
      amount = models.IntegerField(default=0)
  </code></pre>
  
  <p>For 1 cart object created, I can insert as many as new TransactionDetail object (the product and amount). My question is. How can I implement the trigger? What I want is whenever a Transaction detail is created, I want the amount of the product's stock is substracted by the amount in the transactiondetail.</p>
  
  <p>I've read about post_save() but I'm not sure how to implement it.
  maybe something like this </p>
  
  <p>when:</p>
  
  <pre><code>post_save(TransactionDetail, 
         Cart) #Cart object where TransactionDetail.cart= Cart.id
  Cart.stock -= TransactionDetail.amount
  </code></pre>