Question: I have a problem with a post\_save function. The function is correctly triggered but the instance doesn't contains the value insereted. I checked the function using ipdb and there is nothing wrong. Simply the ManyToManyField is empty.

The code:

```
@receiver(post_save, sender=Supplier)
def set_generic_locations(sender, instance, **kwargs):
    """ Set the generic locations for the NEW created supplier.
    """
    created = kwargs.get('created')
    if created:
        glocations = LocationAddress.get_generic_locations()

        for location in glocations:
            instance.locations.add(location)

        instance.save()

```

The field used in the instance:

```
locations = models.ManyToManyField(LocationAddress, blank=True)​

```

I don't understand why, but the locations is always empty.

I use django 1.8.8

UPDATE
------

The problem is the django admin. I found an explanation here: <http://timonweb.com/posts/many-to-many-field-save-method-and-the-django-admin/>

The code that solve the problem in the django admin

```
def save_related(self, request, form, formsets, change):
    super(SupplierAdmin, self).save_related(request, form, formsets, change)
    form.instance.set_generic_locations()

```

Answer: 
ManyToManyFields work a little bit differently with signals because of the difference in database structures. Instead of using the post\_save signal, you need to use the [m2m\_changed](https://docs.djangoproject.com/en/1.9/ref/signals/#m2m-changed) signal
For manytomanyfield, you have to save first your parent object () and then add your