title: Django "Cannot add or update a child row: a foreign key constraint fails"
body: <p>I have a model <code>Coupon</code>, and a model <code>Photo</code> with a <code>ForeignKey</code> to it:</p>
  
  <pre><code>class Photo(models.Model):
      coupon = models.ForeignKey(Coupon,
                                 related_name='description_photos')
      title = models.CharField(max_length=100)
      image = models.ImageField(upload_to='images')
  </code></pre>
  
  <p>I set up inlines in the admin so now I'm able to add photos to a coupon from the admin.</p>
  
  <p>I attempt to add one, and upload is successful, but then I get Django's debug page with this error:</p>
  
  <pre><code>IntegrityError at /admin/coupon/coupon/321/
  (1452, 'Cannot add or update a child row: a foreign key constraint fails (`my_project`.`coupon_photo`, CONSTRAINT `coupon_id_refs_id_90d7f06` FOREIGN KEY (`coupon_id`) REFERENCES `coupon_coupon` (`id`))')
  </code></pre>
  
  <p>What is this and how can I solve this problem?</p>
  
  <p>(If it matters, this is a MySQL database.)</p>
  
  <p><strong>EDIT:</strong> I tried it on an Sqlite3 database that has a slightly different dataset, and it worked, so perhaps there's loose data in my current DB? How can I find it and delete it?</p>