-
-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cascading bug on deletion (Django 1.8) #160
Comments
Seeing this same bug on a very similar model setup (multiple levels of inheritance with django-polymorphic models, various ForeignKey fields). Django==1.8.7 Our workaround is to handle cascading deletes by overriding delete(), but it's a less than ideal solution. Let me know if there's any information I can provide, but Martin's bug report above is basically the same as what we've got on our end of things. |
Affects me too |
I'm getting this as well. Very frustrating. @dsilvers Overriding delete may well be the only solution, I'll look into it. Has it affected performance at all? @chrisglass Would you accept a pull request for delete being overridden? |
@bonniejools No idea on performance. We have a total of zero users currently. |
@bonniejools I'm curious what you've overwritten. Does the issue also occur on standard Django models, or only when the polymorphic models/managers are used? |
Workaround looks something like this, based on @martinmaillard's example at top:
|
I had the same problem, using the polymorphic model with Django 1.9.2 and django-polymorphic 0.8.1 and 0.9.1. What worked for me, was calling delete on each object instead of on the queryset. I.e, the following approach caused integrity error: whereas the following worked just fine: where class A is a PolymorphicModel No need for overriding the delete method |
Also seeing this bug, Django 1.8.9, django-polymorphic 0.8.1
|
Django Polymorphic has a known issue with certain types of bulk queryset deletes. This patch is a temporary workaround to get django soft-delete to work with our system. (jazzband/django-polymorphic#160)
any update on this? |
Really? This is still an issue, basic django functionality. Why are the dev's working on exotic problem xyz when this doesn't even work... |
Can confirm this is still happening to me |
We just run into the same issue with Django 1.10.6 and django-polymorphic 1.1 |
At the moment i fixed it with:
|
My last fix only solved the problem if the deletion starts within a Polymorphic Model.
|
Why waste your time on workarounds instead of simply fixing it properly in the django-polymorphic codebase? PRs welcome. |
So what would a "proper" fix be? I'll submit the PR if someone can explain what needs to happen. |
@TZanke Thanks, It worked for me on Django 1.11 and django-polymorphic 1.13 |
Still affected. |
Still doesn't work for me either... |
But if we change the manager, polymorphic model looses the ability to cast children to appropriate type! How to deal with it? Could someone explain? |
Any updates on this? |
I'm using this custom function for
I think this should be documented as the solution so this issue can be closed. |
Just want to say:
For now, I'll go with this. For anyone wanting a more understandable solution, here it is. models.py
Create a user and some posts and notes and a bookmark.
See the user's content:
Now try to delete user instance:
Solution Is To...
Make migrations and migrate:
Get the user again
|
I have something similar to the following situation:
In code:
If I try to delete an instance of
A
, the following error occurs:The full example and traceback:
I'm not 100% sure it is caused by django-polymorphic, but I could not reproduce the error without it...
The text was updated successfully, but these errors were encountered: