When a new record is added to the table, I have to execute the SQL statement in the external database. This request includes the use of ManyToManyField. So I just hooked up the function as follows:
post_save.connect(post_save_mymodel, sender=MyModel)
And in my post_save_mymodel () function, here is what I do:
def post_save_mymodel(sender, instance, created, *args, **kwargs): if created: for e in instance.my_m2mfield.all():
But too bad, instance.my_m2mfield.all () is always empty! Although they should contain some elements! I tried to get a new item by doing
new_element = MyModel.objects.get(pk=instance.pk)
but it doesnβt change anything, I still have the same problem ...
Helpful help / advice?
source share