You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a bug related to wagtail/wagtail#5437, which added exception handling for deletion of objects that throw a ProtectedError.
I observed that the existing code does not work if the ForeignKey/OneToOneField relationship uses related_name="+".
AttributeError at /admin/videos/video/delete/18/
'Video' object has no attribute '+'
...
Exception Location: /wagtail/contrib/modeladmin/views.py in post, line 814
The code at line 814 is qs = getattr(self.instance, rel.get_accessor_name()), and it makes sense that the code fails when rel.get_accessor_name() == "+".
Steps to Reproduce
Start a new project with wagtail start myproject
Create a videos app with a Video model (code sample below)
Create a VideoPage model (code sample below)
Register the model admin (code sample below)
Create a couple sample videos and video pages
Select a video in the admin interface that is associated with a page, and delete the video
Any other relevant information. For example, why do you consider this a bug and what did you expect to happen instead?
The workarounds for this scenario I'm aware of are:
Don't use PROTECT
Don't use related_name="+"
This is appealing, but becomes a nuisance when using inheritance, because the related_name needs to be unique. The solution I found was to inject the class name into the related_name: related_name="%(app_label)s_%(class)s_related_pages",
I have confirmed that this issue can be reproduced as described on a fresh Wagtail project: no
Technical details
Python version: 3.6
Django version: 2.2.17
Wagtail version: 2.11.3
Browser version: Edge 87
The text was updated successfully, but these errors were encountered:
Issue Summary
This is a bug related to wagtail/wagtail#5437, which added exception handling for deletion of objects that throw a ProtectedError.
I observed that the existing code does not work if the ForeignKey/OneToOneField relationship uses related_name="+".
The code at line 814 is
qs = getattr(self.instance, rel.get_accessor_name())
, and it makes sense that the code fails whenrel.get_accessor_name() == "+"
.Steps to Reproduce
wagtail start myproject
Any other relevant information. For example, why do you consider this a bug and what did you expect to happen instead?
The workarounds for this scenario I'm aware of are:
related_name="%(app_label)s_%(class)s_related_pages",
Technical details
The text was updated successfully, but these errors were encountered: