title: Create objects from one model based on new object in another model (Django)
body: <p>Fairly new to Django (1.2), but just testing stuff out.</p>
  
  <p>My headache is figuring out a way to create a series of SKU objects when a Product object is created.</p>
  
  <pre><code>class Product(models.Model):
      name = models.CharField(max_length=255, unique=True)
      style = models.CharField(max_length=50)
      colors = models.ManyToManyField(Color)
      sizes = models.ManyToManyField(Size)
  </code></pre>
  
  <hr>
  
  <pre><code>class SKU(models.Model):
      id = models.CharField(max_length=15, unique=True, primary_key=True)
      style = models.ForeignKey(Product)
      color = models.ForeignKey(Color)
      size = models.ForeignKey(Size)
      quantity = models.IntegerField(default=0)
  </code></pre>
  
  <p>I initially tried to handle this in Product.save, but alas, no dice. I then tried this signals setup:</p>
  
  <pre><code># models.py
  def create_skus(sender, instance, *args, **kwargs):
      if 'created' in kwargs:
          if kwargs['created']:
              for x in instance.colors.select_related():
                  for y in instance.sizes.select_related():
                      sku = instance.style
                      sku += instance.x.shortcode
                      sku += instance.y.name
                      s = SKU(id=sku, style=instance, color=x, size=y)
                      s.save()
  
  ... # after the Product class
  post_save.connect(create_skus, sender=Product)
  </code></pre>
  
  <p>Some examples I've seen call for the sender class save method to have something like this:</p>
  
  <pre><code>def save(self):
      post_save.send(create_skus, self)
  </code></pre>
  
  <p>...and that's where I'm at. This setup doesn't throw any errors, but it also doesn't create said SKUs.</p>
  
  <p>If I'm way off on any of this signals-wise, any pointers would be appreciated. Or if there's another technique to accomplish a similar feat, that would be wonderful as well.</p>
  
  <p>Cheers!</p>