We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi, I'm writing this issue because I think the AFTER_DELETE hook does not work as expected on m2m relationships. If we have something like that:
class Product(LifecycleModel): title = models.Charfield(max_length=100) images = models.ManyToManyField( to="ProductImage", through="ProductImageRelationship", related_name="products" ) class ProductImageRelationship(LifecycleModel): product = models.ForeignKey("Product", on_delete=models.CASCADE) image = models.ForeignKey("ProductImage", on_delete=models.CASCADE) order = models.IntegerField(default=0, help_text="Lower number, higher priority") class ProductImage(LifecycleModel): field_name = models.CharField(max_length=40)
If I write a hook on ProductImageRelationship model like this:
ProductImageRelationship
@hook(AFTER_DELETE, on_commit=True) def deleting_image(self): print("Image deleted...")
the hook is never triggered when I do
p = Product.objects.get(pk=123) i = p.images.first() # to remove image from product do p.images.remove(i) # or do this i.products.remove(p)
However, If I add a receiver like this:
@receiver(post_delete, sender=ProductImageRelationship) def deleting_image(sender, instance, **kwargs): print("Image deleted...")
The receiver is triggered as is expected.
I think I'm doing it correctly 😕 but I'm not sure completely.
The text was updated successfully, but these errors were encountered:
Refer to issue #120, it is not possible to use Django-lifecycle with a through model for a Many to Many.
Sorry, something went wrong.
No branches or pull requests
Hi,
I'm writing this issue because I think the AFTER_DELETE hook does not work as expected on m2m relationships.
If we have something like that:
If I write a hook on
ProductImageRelationship
model like this:the hook is never triggered when I do
However, If I add a receiver like this:
The receiver is triggered as is expected.
I think I'm doing it correctly 😕 but I'm not sure completely.
The text was updated successfully, but these errors were encountered: