Closed as not planned
Closed as not planned
Description
Description
I have a custom plugin that I am unable to delete from my page. The error returned says:
MySQLdb._exceptions.IntegrityError: (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (`oekf$default`.`oekf_contactinfo`, CONSTRAINT `oekf_contactinfo_cmsplugin_ptr_id_e68f18e6_fk_cms_cmsplugin_id` FOREIGN KEY (`cmsplugin_ptr_id`) REFERENCES `cms_cmsplugin` (`id`))’)
Error seems to occur when the system tries to delete the plugin from the cms_cmsplugin
table, although it has not deleted the actual plugin from my custom table oekf_contactinfo
. I am not sure why the row in the custom table exists at this point… Should it have been deleted previously?
This is the part of the stack trace where the deletion occurs.
File "/home/oekf/.virtualenvs/oekfpy39/lib/python3.9/site-packages/cms/admin/placeholderadmin.py", line 1065, in delete_plugin
plugin.delete()
File "/home/oekf/.virtualenvs/oekfpy39/lib/python3.9/site-packages/cms/models/pluginmodel.py", line 484, in delete
super().delete(*args, **kwargs)
This is my custom plugin definition:
class ContactInfo(CMSPlugin):
redirect_title = models.CharField(max_length=50)
some_field = models.CharField(max_length=50, null=True)
some_other_field = models.CharField(max_length=50, null=True)
class ContactInfoPlugin(CMSPluginBase):
model = ContactInfo
render_template = "components/contact_info.html"
name = _("Contact_info")
cache = False
def render(self, context, instance, placeholder):
context['instance'] = instance
# context being constructed with business logic… this code has been removed on purpose
return context
plugin_pool.register_plugin(ContactInfoPlugin)
Steps to reproduce
- On my page, navigate to the plugin overview for that page
- Select to delete the custom plugin
- "Error 500” occurs in a ‘toast’ at the top of the page and the plugin is not deleted.
Expected behaviour
I expect that the plugin contents can be deleted from the CMS.
Actual behaviour
See description and steps to reproduce.
Screenshots
None relevant
Additional information (CMS/Python/Django versions)
Python: 3.9
Django CMS: 3.10.1
Django: 3.2.21
I am running the application on Pythonanywhere.
Do you want to help fix this issue?
- Yes, I want to help fix this issue and I will join #workgroup-pr-review on Slack to confirm with the community that a PR is welcome.
- [ x] No, I only want to report the issue.