I have several custom page content types of the form:
class MyWidget(models.Model):
...fields...
class Meta:
abstract = True
verbose_name = _('my widget')
verbose_name_plural = _('my widgets')
Page.create_content_type(MyWidget)
If I add these to a page, and later try and delete the page I get the IntegrityError exception:
IntegrityError at /admin/page/page/82/delete/
(1451, 'Cannot delete or update a parent row: a foreign key constraint fails (mydatabase.page_page_mywidget, CONSTRAINT parent_id_refs_id_54aa763d FOREIGN KEY (parent_id) REFERENCES page_page (id))')
I'm assuming this is due to an inappropriate Django ondelete handler on FK field for the page_page_mywidget table autogenerated by Page.create_content_type().
Ideally, when a page is deleted, any rows in content type tables linked to the deleted page should also be deleted. I believe this corresponds to the CASCADE ondelete behavior.
A slow and frustrating workaround is to manually delete all content types on the page, save the page, and then delete the page.