I've a simple signals which is launch when the object is deleted
@receiver(post_delete, sender=Operation, dispatch_uid="delete_operation")
def delete_operation(sender, instance, **kwargs):
# Track balance operations for delete
instance.user.balance = instance.user.balance - int(instance.amount) # Note the "-"
instance.user.save()
The problem is that when I delete the object into the admin, the signals is launch twice and false my balance. I would like to avoid the 2 times trigger. I searched on stackoverflow and tried several solutions but still not working.
Here is how I import the signals :
apps.py
class CommonConfig(AppConfig):
name = 'sl.common'
def ready(self):
import sl.common.signals
If anyone has ideas it's welcome !!