-
Notifications
You must be signed in to change notification settings - Fork 122
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
how does SOFT_DELETE_CASCADE work? #202
Comments
I have the same issue. After I check the Django & safedelete source code, this is because you set the Null=True in your model. https://docs.djangoproject.com/en/3.2/_modules/django/db/models/deletion/ django-safedelete/safedelete/models.py Lines 244 to 274 in 179288b
|
this is quit annoying as I must keep Null=True for some models, is there a workaround? |
I’ve found a workaround by saving the pk list of related soft deleted objects before the soft deletion and then reassigning the parent id to these after the soft deletion... quite cumbersome. is any willing to make a patch for this bug? my level of coding is not high enough unfortunately... @Gagaro ? |
Indeed I'm not sure how to fix that, maybe we should have our own CASCADE which does not set the other field as null. I'll gladly review a PR if someone is willing to try and patch this. |
Having this would be great. For now we are stuck with |
let’s say I have 2 models A and B, B has a foreign key pointing to A and other have soft delete with policy SOFT_DELETE_CASCADE.
If I soft delete an object in A, then the related object in B gets soft deleted as well BUT it seems its foreign key field point to A is set to NULL... which loses the link between object A and object B when I later want to undelete object A.
Is it the intended behaviour?
The text was updated successfully, but these errors were encountered: