title: Django: Adding objects to a related set without saving to DB
body: <p>I'm trying to write an internal API in my application without necessarily coupling it with the database.</p>
  
  <pre><code>class Product(models.Model):
      name=models.CharField(max_length=4000)
      price=models.IntegerField(default=-1)
      currency=models.CharField(max_length=3, default='INR')
  
  class Image(models.Model): 
      # NOTE -- Have changed the table name to products_images
      width=models.IntegerField(default=-1)
      height=models.IntegerField(default=-1)
      url=models.URLField(max_length=1000, verify_exists=False)
      product=models.ForeignKey(Product)
  
  def create_product:
      p=Product()
      i=Image(height=100, widght=100, url='http://something/something')
      p.image_set.add(i)
      return p
  </code></pre>
  
  <p>Now, when I call create_product() Django throws up an error:</p>
  
  <pre><code>IntegrityError: products_images.product_id may not be NULL
  </code></pre>
  
  <p>However, if I call p.save() &amp; i.save() before calling p.image_set.add(i) it works. Is there any way that I can add objects to a related object set without saving both to the DB first?</p>