I've got a model
Coupon, along with a model
Photo having a
ForeignKey into it:
class Photo(models.Model): coupon = models.ForeignKey(Coupon, related_title='description_photos') title = models.CharField(max_length=100) image = models.ImageField(upload_to='images')
I setup inlines within the admin now I am in a position to add photos to some coupon in the admin.
I aim to include one, and upload is effective, however I recieve Django's debug page with this particular error:
IntegrityError at /admin/coupon/coupon/321/ (1452, 'Cannot add or update a young child row: an overseas key constraint fails (`my_project`.`coupon_photo`, CONSTRAINT `coupon_id_refs_id_90d7f06` FOREIGN KEY (`coupon_id`) REFERENCES `coupon_coupon` (`id`))')
What's this and just how can one solve this issue?
(Whether it matters, this can be a MySQL database.)
EDIT: I attempted it with an Sqlite3 database which has a slightly different dataset, also it labored, so possibly there's loose data during my current DB? How do i think it is and remove it?
A number of my tables were in InnoDB plus some were in MyISAM... I transformed everything to MyISAM and also the problem was solved.
To avert this happening what you could also do is placed your
STORAGE_ENGINE inside your configurations.py
for django >= 1.2
for django <= 1.2
DATABASE_STORAGE_ENGINE = "MyISAM / INNODB / ETC"
Please be aware this really is only valid for MySQL